Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse proxy for host service #4

Open
SYip opened this issue May 28, 2017 · 1 comment
Open

Reverse proxy for host service #4

SYip opened this issue May 28, 2017 · 1 comment

Comments

@SYip
Copy link

SYip commented May 28, 2017

Hello, I would like to ask how could I config it to reverse proxy to host service port 5000. I am not fimiliar with nginx config.

@hartmark
Copy link

hartmark commented Jul 5, 2022

I had same question myself and it was a bit tricky to get sorted.

You can use the sample web site and add a "qb.conf" under this folder:
./docker-nginx-letsencrypt-sample/volumes/nginx-sample-website/conf.d

With this content:

upstream qb_host {
  # specify extra-host in docker-compose.yml or specify IP here straight away
  server host.docker2.internal:8080;
}

server {
  location /qb {
    proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;

    proxy_set_header Upgrade           $http_upgrade;
    proxy_set_header Connection        "upgrade";
    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-Port  $server_port;

    # add a trailing slash if just ending with /qb
    rewrite ^([^.]*qb[^/])$ $1/ permanent;

    # drop qb from url
    rewrite ^/qb/?(.*)$ /$1  break;
    proxy_pass https://qb_host;
  }
}

Then you need to add this to the end of the docker-compose.yml:

    extra_hosts:
      - host.docker2.internal:192.168.1.50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants