1

I have configured my instance to serve 5-6 apps on different domains using vhosts. I want to access those apps using SSH tunneling using local port forwarding to make some modifications. This is required due to security concerns and i don't want to perform modifications over public internet. I can access all domains via public networks but when connected to instance via SSH tunneling i can access only default vhost on 127.0.0.1/localhost. How can i access rest of apps through tunneling?

127.0.0.1/8888 opens my default vhost I want to access other vhosts as below if possible site1.127.0.0.1:8888 or 127.0.0.1:8888/site1 site2.127.0.0.1:8888 or 127.0.0.1:8888/site2

Rohit
  • 11
  • 3
  • Depends how you configured your VirtualHosts. Do they all listen on the same port, same ip? If so, then Apache needs to know the domain name you want, to split traffic between the different VirtualHosts. So setup your SSH tunnel, configure the desired domain to point to 127.0.0.1 in your local /etc/hosts file, and put that domain name in your browser. This way the browser will go to that domain, which is your local IP, which is your tunnel. The important detail is that Apache gets which domain name you want in the requests. – Nic3500 Apr 07 '23 at 05:00
  • Thanks for repsonse, Nic. Yes they all listen to standard 80 port and same IP. I can open one app/domain which is default vhost using http://127.0.0.1:8888/ using SSH tunnel when port 80 on server is mapped to port 8888 on my pc. I want to access all of them simultaneously through SSH tunnel maybe through changing vhosts file just once, without altering vhost order or doing any temporary modifications or hacks every time i need to access any one of many apps. – Rohit Apr 08 '23 at 10:07

1 Answers1

0

Try this, I am not certain it will work, but it takes too much space for a simple comment.

Assuming your server has:

On your laptop try this setup:

  • SSH tunnel, local port 8880, server port 80
  • /etc/hosts
  • Make sure your system is configured to accept DNS names configured via files (nsswitch.conf, hosts: files)

Then in your browser, open these URLs:

This way the http request will contain the domains you want Apache to see to split traffic between the VirtualHosts. But since the domains resolve to your local address, it should go through the SSH tunnel.

Nic3500
  • 8,144
  • 10
  • 29
  • 40