参考说明:https://blog.csdn.net/qq_39198749/article/details/119734364
location /demo/ {
proxy_pass http://172.16.3.66/;
}
asp.net mvc 项目节点配置
配置的 proxy_pass 注意
proxy_pass http://172.16.3.66/;
斜杠要注意配置,有时候会影响到404
还有就是 转发的时候没把 路由标签带上
最后我还是放弃了 /Demo/ 的配置,采用多server 配置。原因是要修改全部代码的路由配置。不知道为什么asp.net 不前后端分离,怎么在发布的时候添加basePath 前缀,像Vue的话 打包都可以。
比如说 /demo/ 转发的时候没把 /demo/ 带上,导致js css 读取到根目录获取不到 404
server {
listen 80;
server_name www.baidu.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://172.16.4.210:8081;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 18000;
proxy_send_timeout 18000;
proxy_read_timeout 18000;
root html;
index index.html index.htm;
}
#这里我放弃了。原因 配置的 / 如果 删掉就404 加上就要改动项目整体路径的路由
location /ESG {
proxy_pass http://172.16.4.204:9005/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name ESG.baidu.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://172.16.4.204:9005;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 18000;
proxy_send_timeout 18000;
proxy_read_timeout 18000;
root html;
index index.html index.htm;
}
}
![]()