我在 Nginx 后面安装了 Grafana,作为它的反向代理运行,然后在 Cloudflare 后面运行。不幸的是,当我尝试访问它时,它卡在跳转 Grafana 徽标上,下面有“正在加载”字样。
Grafana 有望在子域名(如 grafana.domain.com)上访问。
我尝试更改 Nginx vhost 和 grafana.ini 中的配置,但没有成功。我当前的 Nginx 配置:
server {
listen 80;
server_name grafana.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen *:443 ssl http2;
server_name grafana.domain.com;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_prefer_server_ciphers off;
resolver 1.1.1.1 8.8.8.8;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" always;
proxy_redirect off;
client_max_body_size 100M;
proxy_read_timeout 3000s;
proxy_send_timeout 3000s;
access_log /var/log/nginx/grafana-access.log;
error_log /var/log/nginx/grafana-error.log warn;
location / {
allow 1.2.3.4/32;
allow 2.3.4.5/29;
deny all;
proxy_ssl_verify off;
# proxy_redirect off;
# proxy_hide_header Upgrade;
proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Server $host;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Server-Address $server_addr;
proxy_pass http://localhost:3000;
# proxy_http_version 1.1;
# proxy_cache_bypass $http_upgrade;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# proxy_set_header X-Forwarded-Port $server_port;
}
}
我还尝试将 Grafana 配置更改为:
[server]
;protocol = http
;http_addr =
;http_port = 3000
domain = grafana.domain.com
;enforce_domain = false
root_url = %(protocol)s://%(domain)s:%(http_port)s/
serve_from_sub_path = true
但这也不起作用。
答案1
如果您禁用 CF 代理并且能够访问 Grafana,请尝试以下端口 --> 2087