2

My home setup is as follows:

Internet -> pfsense router -> Multiple Windows 7 machines Ubuntu NAS w/Webmin

I have dynamic DNS setup so I have www.domainname.com updating with the pfsense WAN box

For example having the java VNC web-server on 2 of the windows 7 machines, I can have it setup so that, for example:

www.domain.com:5800 is PC1 www.domain.com:5901 is PC2

What I want to know is if it is possible to install apache on the ubuntu box, forward port 80 traffic to it, and set it up to have eg

www.domain.com/PC1 redirect to PC1 java vnc server on default port www.domain.com/PC2 redirect to PC2 vnc etc..

If it is possible, some pointers would be appreciated.

2 Answers 2

2

try apache rewrite engine. something like:

<VirtualHost ubuntu:80>
    ServerName domainname.com
    RewriteCond %{REQUEST_URI}      ^/PC1
    RewriteRule ^/(.*)$             http://pc1:5800/$1 [R=permanent,L]
    RewriteCond %{REQUEST_URI}      ^/PC2
    RewriteRule ^/(.*)$             http://pc1:5901/$1 [R=permanent,L]
</VirtualHost>

update. i just realised that you might as well have these two PCs not available from the internet, ie behind the router with no external IPs. in that case you have to modify the above, so it redirects requests to the same ubuntu machine on different ports and then does a proxy pass to local windows servers:

<VirtualHost ubuntu:80>
    ServerName domainname.com
    RewriteCond %{REQUEST_URI}      ^/PC1
    RewriteRule ^/(.*)$             http://ubuntu:5800/$1 [R=permanent,L]
    RewriteCond %{REQUEST_URI}      ^/PC2
    RewriteRule ^/(.*)$             http://ubuntu:5901/$1 [R=permanent,L]
</VirtualHost>

<VirtualHost ubuntu:5800>
    ServerName domainname.com
    ProxyPass / http://pc1:5800/
    ProxyPassReverse / http://pc1:5800/
</VirtualHost>

<VirtualHost ubuntu:5901>
    ServerName domainname.com
    ProxyPass / http://pc2:5901/
    ProxyPassReverse / http://pc2:5901/
</VirtualHost>

uff... hope this helps... :)

4
  • Thank you I will try this when I get home. If the default port for vnc java viewer is 5800, can i set up virtual servers ubuntu:5800, ubuntu:5801 etc that all point to port 5800 on the respective machines?
    – Dave
    Feb 15, 2010 at 15:17
  • if it's http traffic then yes. alternatively you might want to think about using iptables to do forwarding for you, but that might get a bit messy....
    – pulegium
    Feb 15, 2010 at 15:19
  • Why not just ProxyPass /PC1 http://pc1:5901/ and ProxyPAss /PC2 http://pc2:5901/ (with the ProxyPassReverse for both)? Why do that extra work with RewriteRules? See my answer.
    – Bill Weiss
    Feb 15, 2010 at 15:53
  • hmm.. good point.. :) well, this allows you to have two options: either use domain/pc1 or domain:5800 notion... but you right, your option is simpler...
    – pulegium
    Feb 15, 2010 at 17:46
1

Try this:

<VirtualHost ubuntu:80>
  ServerName domainname.com
  ProxyPass /PC1 http://pc1:5901/
  ProxyPassReverse /PC1 http://pc1:5901/
  ProxyPass /PC2 http://pc2:5901/
  ProxyPassReverse /PC2 http://pc2:5901/
</VirtualHost>

Much easier than messing with RewriteRule

You must log in to answer this question.