3

I've been looking for a while to the answer to this question and I seem to find slightly different needs from people asking questions and they get wildly different answers... but none of them seem to fit my problem.

I have a server that uses (successfully) mod_proxy to redirect subdomains of my main domain to other machines on my network, however I always need to specify the port like so

<VirtualHost *:80>
    ServerName sub.domain.com
    ProxyPreserveHost On
    ProxyPass / http://192.168.1.123/
    ProxyPassReverse / http://192.168.1.123/
</VirtualHost>

What I want to accomplish is to redirect any type of connection to that subdomain AND the specified port to a different machine so something like

<VirtualHost *:*>
    ServerName sub.domain.com
    ProxyPreserveHost On
    ProxyPass / http://192.168.1.123/
    ProxyPassReverse / http://192.168.1.123/
</VirtualHost>

so it would translate to

sub.domain.com:1234 => 192.168.1.123:1234

sub.domain.com:5678 => 192.168.1.123:5678

etc... the documentation official documentation seems to suggest it is possible by passing : but when I do I land on my default page on my server...

3
  • You might be able to use ReWrite, and set a variable for the port no. httpd.apache.org/docs/2.4/rewrite/proxy.html – Angelo Mar 5 '17 at 5:12
  • I think my question was not clear enough... What I need to do is to forward any implicit or explicit port used to connect to the sub-domain... So if an application tries to connect to sub.domain.com expecting port 1234 to be open that should point to the IP of my second machine... So basically no matter what port is passed (or not passed) all connection to that URL should go to the set IP. – TonyMorello Mar 6 '17 at 1:04
  • Rewrite rules allow you to assign the port number in the URL to a variable, which you can pass as a variable to your internal address. – Angelo Mar 8 '17 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.