多種情況驗(yàn)證
假設(shè)請(qǐng)求:http://localhost/api/login
第一種情況
proxy_pass結(jié)尾有/
代理后的實(shí)際地址:http://localhost:8080/login
location /api/ {
proxy_pass http://localhost:8080/;
proxy_set_header X-Real-IP $remote_addr;
}
第二種情況
proxy_pass結(jié)尾沒有/
代理后的實(shí)際地址:http://localhost:8080/api/login
location /api/ {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
}
第三種情況
proxy_pass最后有/web
代理后的實(shí)際地址:http://localhost:8080/weblogin
location /api/ {
proxy_pass http://localhost:8080/web;
proxy_set_header X-Real-IP $remote_addr;
}