我对nginx反向代理背后的qgis系统有问题.有些请求在nginx上请求时会产生404 --如果没有nginx,则不会发生404错误。
我将发布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;
}现在有问题的请求:
在nginx-log中:
-18/ /kommunalportal/index.php/view/media/illustration?repository=kp&project=m01_Klostermansfeld /2019:09:59:54 +0200 "GET geodatenportal.domain.tld HTTP/2.0“404 72 "https://geodatenportal.domain.tld/kommunalportal/index.php/view/”(WindowsNT10.0;( "172.28.136.21:80/kommunalportal/index.php/view/media/illustration?repository=kp&project=m01_Klostermansfeld“)WOW64/537.36(WOW64,类似壁虎) Chrome/76.0.3809.132 Safari/537.36”-“0.031 172.28.136.21:80 -WOW64
对于顶部的日志配置,粗体字符串应该是对后端的请求。
但是apache记录的内容如下:
194.113.79.210 -18/9/2019:09:59:54 +0200 "GET /kommunalportal/index.php/view/media/illustration HTTP/1.1“404 72
因此,从nginx到apache的过程中,get参数似乎丢失了。
有人能解释一下吗?
发布于 2019-09-18 09:45:44
您可以使用regex位置来匹配URI,然后在proxy_pass中使用它。NGINX正则表达式位置匹配是针对没有参数的URI完成的。
如果您想传递它们,只需按如下方式添加:
proxy_pass http://backend-geodatenportal/kommunalportal$1$is_args$args;https://stackoverflow.com/questions/57989551
复制相似问题