0
votes

i have a problem with a qgis-system behind a nginx reverse-proxy. some requests will result in 404 when requested over nginx - without nginx the 404 errors do not happen.

i will post some vital parts of the nginx-config:

log_format  main  '$host $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_addr $upstream_http_status  "$upstream_addr$request_uri"';
access_log /data/logs/nginx/access.log main buffer=4k;

upstream backend-geodatenportal {
    ip_hash;
    zone http_backend 256k;
    server 172.28.136.21:80 weight=1 max_fails=3  fail_timeout=30s;
    keepalive 1024;
}
server {

    listen          geodatenportal.domain.tld:443 ssl;
    server_name     geodatenportal.domain.tld;
    ...
    location / {
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host $host;
        proxy_set_header ClientProtocol https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://backend-main;
    }

    location ~/kommunalportal(.*)$ {
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host $host;
        proxy_set_header ClientProtocol https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://backend-geodatenportal/kommunalportal$1;
    }

now the requests with problems:

in nginx-log:

geodatenportal.domain.tld - $IP - - [18/Sep/2019:09:59:54 +0200] "GET /kommunalportal/index.php/view/media/illustration?repository=kp&project=m01_Klostermansfeld HTTP/2.0" 404 72 "https://geodatenportal.domain.tld/kommunalportal/index.php/view/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" "-" 0.031 172.28.136.21:80 - "172.28.136.21:80/kommunalportal/index.php/view/media/illustration?repository=kp&project=m01_Klostermansfeld"

with the log-configuration from top the bold string should be the request to the backend

but this is what apache logs:

194.113.79.210 - - [18/Sep/2019:09:59:54 +0200] "GET /kommunalportal/index.php/view/media/illustration HTTP/1.1" 404 72

so it seems the GET-Parameters get lost on its way from nginx to apache

can someone explain this?

1

1 Answers

1
votes

You use regex location to match against URI, then use it in proxy_pass. The NGINX regex location matching is done against URI without arguments.

If you want to pass them on, just add them like so:

proxy_pass http://backend-geodatenportal/kommunalportal$1$is_args$args;