How to access the web page using specific port?

Posted on

How to access the web page using specific port? – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, iptables, apache-2.4, port, port-forwarding.

I created two directories for storing the website on the web server

/web
/web/admin

Assume that my website domain is http://www.domain.com/ and I would like to using the port 8080 for the admin page.

How can I restrict the url http://www.domain.com:8080 point to /web/admin and the http://www.domain.com:80 still point to /web?

I know most of web control panel doing like that. Can anyone guide me how I can do this?

Here is my environment: Linux CentOS 7.0, Apache/2.4.6

Solution :

If you want to do it manually, edit the file nano /etc/apache2/sites-enabled/000-default.conf

and change your virtual host configuration :

<VirtualHost *:80>
# [ Server Domain ]
ServerName www.domain.com
# [ Server Root ]
DocumentRoot /web/
# [ Prevent direct access to admin]
Redirect 301 /admin/ http://www.domain.com:8080
</VirtualHost >

Listen 8080
<VirtualHost *:8080>
# [ Server Domain ]
ServerName www.domain.com
# [ Server Root ]
DocumentRoot /web/admin/
</VirtualHost >

By the way sites-enabled/000-default.conf is a symbolic link of sites-available/000-default.conf

You should set your web site and admin site in two separate folder to have two clean virtual host, without protecting direct access with a redirect

You can set listening port in /etc/apache2/ports.conf instead of your website configuration if you want

Leave a Reply

Your email address will not be published.