我需要通过删除一部分url来传递一些请求代理(运行GlassFish).
例如:
https://xxx.net/jazz/MobileApi?id=2&make_id=4
应该传递给代理:
http://X.X.X.X:8080/MobileApi?id=2&make_id=4
我有以下Nginx配置:
upstream vito_api {
server 178.63.X.X:8080;
}
server {
listen 80;
listen 443 ssl;
....
location ~ /jazz/(?
但是,不幸的是,请求传递没有参数.
因此,在GlassFish访问日志中,我只能看到:
"148.251.X.X" "NULL-AUTH-USER" "05/Jan/2015:15:18:40 +0100" "GET /MobileApi/ HTTP/1.0" 200 21
我做错了什么?
如何传递URL参数?
谢谢.
最佳答案
从nginx’s documentation(上下文:前缀位置)
原文链接:https://www.f2er.com/nginx/435577.htmlIf the proxy_pass directive is specified with a URI,then when a request is passed to the server,the part of a normalized request URI matching the location is replaced by a URI specified in the directive.
因此可以通过以下方式简化:
location /jazz/ {
proxy_pass http://vito_api/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}