nginx 反向代理转发导致css,js,图片失效

时间:2023-03-08 19:14:43

需要添加以下配置


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
proxy_pass https://localhost:7443;
}
location ~ .*\.(js|css)$ {
proxy_pass https://localhost:7443;
}

完整的配置

   

  listen     443 ssl;
server_name localhost;
ssl on;
ssl_certificate /app/weixin/certificate/server.crt;
ssl_certificate_key /app/weixin/certificate/server.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on; location ^~ /mp/ {
proxy_pass https://localhost:6443/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect http:// $scheme://;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /dubbo/ {
proxy_pass https://localhost:7443/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect http:// $scheme://;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
proxy_pass https://localhost:7443;
}
location ~ .*\.(js|css)$ {
proxy_pass https://localhost:7443;
}

参考网站:
http://www.360doc.com/content/14/0616/12/203871_387137334.shtml
https://blog.csdn.net/kepoon/article/details/73253059

转载于:https://my.oschina.net/jywm/blog/1790197