配置代码:

#PROXY-START/
location /server/ {
    proxy_pass http://shopserver.mchweb.com:8083/; # 斜杠不能少
    proxy_set_header Host shopserver.mchweb.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    add_header X-Cache $upstream_cache_status;
    
    #Set Nginx Cache
    
    add_header Cache-Control no-cache;
}
#PROXY-END/

Nginx 反向代理 二级域名加端口 致 二级目录;


反向代码配置,一定要注意静态文件配置,完整配置如下:

#PROXY-START/
location  ~* \.(gif|png|jpg|css|js|woff|woff2|do)$
{
    proxy_pass http://localhost:8080;
    proxy_set_header Host shop.mchweb.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    expires 12h;
}
location /
{
    proxy_pass http://localhost:8080/;
    proxy_set_header Host shop.mchweb.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    add_header X-Cache $upstream_cache_status;
    #Set Nginx Cache
    add_header Cache-Control no-cache;
}
#PROXY-END/









点赞(0) 打赏

Comment list 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部