subdomain .htaccess redirection via ssh remote port forwarding

Posted by Achim on Server Fault See other posts from Server Fault or by Achim
Published on 2012-06-06T15:52:26Z Indexed on 2012/06/06 16:42 UTC
Read the original article Hit count: 332

Filed under:
|

I ask you to help me URL redirecting a subdomain to a SSH remote forwarded port:

The current setup is the following: The server A have a local webserver running on port 80. This server is connected to a DSL line or a GPRS connection where the IP address changes often. To prevent a DynDNS setup we established a SSH remote port forwarding to a server B with a static IP adress. This is done on server A by the following statement:

ssh -N -p 80 -g -R 10000:localhost:80 tunneling@<Server B IP>

So by accessing the new port 10000 of the servers B IP-adress, all traffic is forwarded to the server A port 80 - this works fine!

But to offer a more comfortable url to the user I want to hide the server B IP-adress and offer a subdomain. My domain provider allows to add subdomains and redirections to some other servers. In general, this works, I've tested this with different servers. But it don't work if the destination is the port forwarded port of server B. The initial redirection is done, the request is send to server A and the response are forwarded to server B and shown in the browser - fine. But then the URL within the browser is switched away from the subdomain to the IP:port of server B. So the user don't see the subdomain in the URL string of the browser anymore.

I've tried this with my providers subdomain redirection, as well as .htaccess redirect, as well as META refresh, the problem always persist.

Is there a parameter in the ssh reverse forwarding setup (I guess this is the place where the fix have to be) to keep the typed in subdomain URL and not show the IP.

Thanks Achim

© Server Fault or respective owner

Related posts about ssh

Related posts about redirect