Grafana Nginx 403 Origin not allowed 及 ws websocket连接错误解决
Grafana Nginx 403 Origin not allowed 及 ws websocket错误解决 ---我超怕的
https://www.cnblogs.com/iAmSoScArEd/p/18514291
注意,这里日志并不全,仅贴了关键解决问题的部分,请勿直接复制粘贴用于生产环境。
http {
# 解决websocket错误 https://nginx.org/en/docs/http/websocket.html
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen 443 ssl;
server_name grafana.xxx.com;
proxy_pass_request_headers on;
location / {
proxy_pass http://grafana_ip:3000;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 解决websocket错误
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# 解决403 Origin not allowed
proxy_set_header Host $http_host;
}
}
}
注意,这里日志并不全,仅贴了关键解决问题的部分,请勿直接复制粘贴用于生产环境。
俗人昭昭,我独昏昏。俗人察察,我独闷闷。