Question

I need to resolve some Cross Domain Policy issues for our team's project setup (Converse.js, XMPP, BOSH, ...) by setting up a nginx reverse proxy configuration.

I want to archieve exactly these bindings:

  • nginx to local gunicorn HTTP server http://my.nginx.server.com/ should proxy http://localhost:8000/

  • nginx to remote HTTP-server for BOSH http://my.nginx.server.com/http-bind should proxy http://some.very.remote.server:5280/http-bind

Currently, only the first binding works. The second one doesn't. nginx delivers every request to the local gunicorn HTTP server and not to the remote server.

This is my nginx.conf:

...
server {
    listen       80;
    server_name  localhost;

    # Reverse proxy for remote HTTP server
    location ~ ^/http-bind/ {
        proxy_pass http://some.very.remote.server:5280;
    }

    # Reverse proxy for local gunicorn HTTP server
    location / {
        proxy_pass http://localhost:8000;
        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_redirect http://$server_name http://$server_name:8000;
    }
    ...
}
Était-ce utile?

La solution

I have found this working configuration:

        location /http-bind {
            proxy_pass http://sapbot.mo.sap.corp:5280/http-bind;
            proxy_set_header Host $host;
            proxy_buffering off;
            tcp_nodelay on;
        }

        location / {
            proxy_pass http://localhost:8000;
            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_redirect http://$server_name http://$server_name:8000;
        }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top