Skip to main content

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:

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


Virtualhost configuration

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

(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)

And your good to go!

Before the Internet

How to redirect 1 domain name to another and correct URL bar

If like me, you want to redirect your old domain name to your new one while correcting the visitors’ URL bar, the solution is quite simple in fact using your VirtualHost.

Here is my example, I wanted to redirect and (Without www) to directly and make sure the domain name change in the visitors’ URL bar, you need to tweak a bit your Vhost located in your


to add the domain name you want to redirect at the beginning of your existing VirtualHost.

Here is the interesting part of mine:



First, the server will answer any request on the port 80, the default HTTP port (*:80) for the ServerName or the Alias and will redirect any folder called (/) to the website

Like that, if you call, it will redirect to Or if you call, it will redirect to

Easy right?