nginx 反向代理报 404?
server
{
listen 80 default_server reuseport;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
root /home/wwwroot/pension_operate_web/dist;
location /api/ {
proxy_pass http://www.baidu.com;
}
.
.
.
}
把/api
改为/
,那么访问ip地址就能反向代理,但是为什么/api/
访问ip:80/api
就报出404了呢?
匹配规则也换了又换,还是不行,不知道为什么。
这样写最终访问的是www.baidu.com/api ,应该是这样吧:
记得代理后面的地址要加
/
访问
/api/
或/api
都可以如果代理地址后面不加
/
,其实访问的真实地址是http://www.baidu.com/api/
当然会是404了,因为百度就没有这个地址