How to redirect a port to a sub-domain – ProxyPass

Very often, you need to connect to a service through it’s dedicated port, for example, Subsonic, will be 4040 (http://mywebsite.tld:4040), Deluge torrent will be 8112 or could be changed to 9092, ….

But it could be complicated to remember all theses ports and if you are behind a proxy that block all the connection except HTTP and HTTPS (80 and 443), you actually may want to set up a subdomain to access your services. In my case, to access my Deluge torrent WebUI, I will prefer to go to without the need to enter the port number.

This could be easily achieve on your LAMP server by tweaking your virtualhost with the variables ProxyPass and ProxyPassReverse.


You will need to install the following packages in root:

apt-get install libapache2-mod-proxy-html

And you will also need to activate the mod-proxy-http (Already installed)

a2enmod proxy_http


Virtualhost configuration

Here is my full Virtualhost for Deluge that you could reuse:


        ProxyRequests Off
        Order deny,allow
        Allow from all
        ProxyPass / http://localhost:9092/
        ProxyPassReverse / http://localhost:9092/

(You need to keep the exact syntax. If for example you forget the / after http://localhost:9092, you will come up with a blank page when you will try to access to the subdomain)

The “/” of ProxyPass and ProxyPassReverse tells Apache that you want to reroute all the connection from the root folder of your Vhost to
You could aslo reroute the website to another folder for example.

Restart your apache server (in root)

/etc/init.d/apache2 restart

And your good to go!

Before the Internet


Loves to discover web-based apps to install on his own server@home and write articles about it


Add a comment