mmatczuk / go-http-tunnel

Fast and secure tunnels over HTTP/2
GNU Affero General Public License v3.0
3.25k stars 308 forks source link

Add host_header modifier in tunnel configuration #18

Open mmatczuk opened 7 years ago

mmatczuk commented 7 years ago

Rewrite the HTTP Host header to this value

jonreeves commented 7 years ago

Would be really useful because most of my projects that run Apache or Nginx are expecting to respond only to a particular Host request.

findmyway commented 7 years ago

Any update here?

I encounter a problem, not sure whether it is related to this thread.

My website is using the 4444 port on the server. By using Nginx, I proxy request to 80 port to my website.

In the meantime, I want to use go-http-tunnel to access my local machine, so I set the go-http-tunnel service listen port 5555(since 80 is already been used). And I write the nginx config as follows:

server{
    listen 80;
    server_name  tunnel.myownsite.com;

    access_log /var/log/nginx/tunnel_access.log;
    error_log /var/log/nginx/tunnel_error.log;

    location / {
        proxy_pass http://localhost:5555/;
        proxy_set_header Host $http_host;
    }
}

The client config is as follows:

server_addr: 52.183.47.200:4567
insecure_skip_verify: true
tunnels:
  webui:
    proto: http
    addr: localhost:8080
    host: localhost

On my server, I can use wget localhost:5555 to access the local machine. Request of tunnel.myownsite.com said

client not subscribed

Thank you very much!

K1Z4 commented 5 years ago

In case anyone else has the same issue:

If you're having issues after using Nginx as a reverse proxy you should try adding the following to your location block:

proxy_set_header Host $host;

More details here