我正在配置nginx revser代理。结果应该是当用户键入http://10.21.169.13/mini
时,请求应为proxy_pass to 192.168.1.56:5000
。这是nginx
配置:
server {
listen 80;
server_name 10.21.169.13;
location = /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
以上location
块从未与http://10.21.169.13/mini
一起使用。唯一有效的location
块是:
server {
listen 80;
server_name 10.21.169.13;
location / {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
但是上面的配置也匹配http://10.21.169.13
请求太多了。
哪个location
块只匹配'http://10.21.169.13/mini`而不再匹配?
更新:尝试了以下内容并失败:
location /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
location /mini/ {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
错误为request not found
。
答案 0 :(得分:1)
试试这个:
server {
listen 80;
server_name 10.21.169.13;
# root /usr/share/nginx/html;
# index index.html index.htm;
location / {
# add something here to handle the root
# try_files $uri $uri/ /index.html;
}
location /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
请告诉我这是否适合您。