Nginx配置tomcat负载均衡,解决css样式丢失问题
增加location ~ .*
即可
http{
upstream gzf {
ip_hash;
server 192.168.2.171:8380;
server 192.168.2.172:8380;
server 192.168.2.173:8380;
server 192.168.2.174:8380;
server 192.168.2.175:8380;
server 192.168.2.176:8380;
server 192.168.2.177:8380;
}
}
server
{
listen 8083 ssl;
server_name 192.168.2.187;
index index.php index.html index.htm default.php default.htm default.html;
root /home/xx;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate /usr/local/nginx/cert/xxx.pem;
ssl_certificate_key /usr/local/nginx/cert/xxx.com.key;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
# 反向代理
location /
{
add_header 'Access-Control-Allow-Origin' '*';
proxy_pass http://gzf/;
proxy_connect_timeout 3000;
proxy_send_timeout 3000;
proxy_read_timeout 3000;
}
location ~ .* {
# 解决css丢失问题
proxy_pass http://gzf;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 解决https代理http Mixed Content和Blockable问题
proxy_set_header Upgrade-Insecure-Requests 1;
proxy_set_header X-Forwarded-Proto https;
add_header Content-Security-Policy upgrade-insecure-requests;
}
access_log /usr/local/nginx/web_content/gzf.xxx.com/gzf.log;
error_log /usr/local/nginx/web_content/gzf.xxx.com/gzf.error.log;
}
标签:tomcat,header,192.168,server,Nginx,proxy,ssl,8380,css
From: https://www.cnblogs.com/zhangruifeng/p/17088516.html