What are private ports?

apacheUsing private (or dynamic ports), allows you to specify your own port, instead of the default port 80 for http traffic.  This article describes how to set this up on an Ubuntu LAMP server.  Note that using private ports won't by itself add to your security very much (hackers could still run a port scan and see the port that you've created).

Visit the apache site for more information.


Private Port Range

There are three distinct ranges of ports in use on the internet...

  1. Well known (privileged) port numbers, 0 - 1023
  2. Registered (user) port numbers, 1024 - 49151
  3. Private (dynamic) port numbers, 49152 - 65535

We therefore must choose a number between 49152 and 65535.  For this example we will use 65000.

 

Listen

We must first configure apache to listen for traffic on our port.

sudo vi /etc/apache2/ports.conf

Below the Listen 80 line add the following

Listen 65000

Note that you could comment out the Listen 80 line, to make your web server only listen for port 65000.

 

Virtual Host

Now we can configure the virtual host

sudo vi /etc/apache2/sites-available/mysite.com

Change two lines as follows...

<VirtualHost *:65000>

ServerName mysite.com:65000

Now we can reload and restart the apache2 service.

sudo service apache2 reload

sudo service apache2 restart

 

Further security issues

You will probably find that port 65000 will need to be opened on a firewall or other security gateway.

 

Thanks for visiting.