Alex
Alex

Reputation: 581

SSH forward port to local host name

I have next setup:

Project VM setup (/etc/hosts on Local host):

192.168.100.102 host1.vm.private
192.168.100.102 sub1.host1.vm.private
192.168.100.102 sub2.host1.vm.private

"host1" subdomains resolved by application router and served by nginx (config for "host1.vm.private" on Project VM):

server {
    listen 80;
    server_name ~^(.+\.)?host1\.vm\.private$;
    ...
}

I need to make "sub(1|2|N).host1.vm.private" reachable from remote host. How this can be done?

Upvotes: 0

Views: 1322

Answers (1)

Alex
Alex

Reputation: 581

So, i found the solution: Trouble SSH Tunneling to remote server

The main issue is that invalid HTTP header was sent and nginx cant resolve a virtual host.

  1. Run on local PC ssh -R 8888:192.168.100.102:80 <remote_pc_credentionals>. Or, run "inversed" command with ssh -L flag on remote PC.

  2. Add "sub1.host1.vm.private" to /etc/hosts on remote PC: 127.0.0.1 sub1.host1.vm.private

OR

  1. Send "Host" header with each request: curl -H "Host: sub1.host1.vm.private" "http://localhost:8888/some/path"

Upvotes: 1

Related Questions