0

i have this config to access geoserver :

location /geoserver {
    proxy_set_header   Host             $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://localhost:8080/geoserver/;
    proxy_pass_header Set-Cookie;
    proxy_redirect off;
    }
}

every this work fine when i access geoserver webpage but nginx not handle requests like this :

http://localhost:8080/geoserver/ows?SERVICE=WMS&access_token=4r3irW5W3DboGs…7091932%2C-5009377.085697312%2C-10018754.17139462%2C-9.313225746154785e-10 

this error appear in console:

GET http://localhost:8080/geoserver/ows?SERVICE=WMS&access_token=4r3irW5W3DboGs…7091932%2C-5009377.085697312%2C-10018754.17139462%2C-9.313225746154785e-10 net::ERR_CONNECTION_REFUSED

i want to nginx to replace http://localhost:8080 with IP

Update

i removed slash but some requests not working well

OPTIONS http://localhost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&TILED=true&VERSION=1.1.1 net::ERR_CONNECTION_REFUSED

i copied the url in browser and replaced localhost:8080 with IP it works!!!

full configrations :

upstream django {
    server unix:///tmp/uwsgi.sock;    # for a file socket
    }

server {
    listen      80;
    server_name XX.XX.XX.XX;
    charset     utf-8;

    #Max upload size
    client_max_body_size 1024M;   # adjust to tast

    location / {
        uwsgi_pass  django;
        include     /etc/nginx/uwsgi_params;
        }
    location /geoserver {
        proxy_set_header   Host             $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://localhost:8080/geoserver;
    proxy_pass_header Set-Cookie;
    proxy_redirect off;

        }
    }
Hisham Karam
  • 101
  • 5

1 Answers1

1

In your question, you have a prefix location and prox_pass statement with a URI. Where you need nginx to perform an aliasing function, the location value and the proxy_pass URI should either both end with a / or neither end with a / or the mapped URI will be malformed.

location /geoserver {
    ...
    proxy_pass http://localhost:8080/geoserver;
    ...
}

See this document for more.

However, in your case, you are mapping /geoserver to /geoserver which is pointless, so the non-URI version of proxy_pass will suffice and will be more efficient:

proxy_pass http://localhost:8080;
Richard Smith
  • 12,834
  • 2
  • 21
  • 29