HTTPS (SSL) 設定
快速導覽
以下說明適用於舊版映像檔。如果您使用新的基於 Docker 的映像檔,請參閱以下指南
https://gist.github.com/arikfr/64c9ff8d2f2b703d4e44fe9e45a7730e
如果您使用提供的映像檔或引導腳本,要開始在您的實例中使用 SSL,您需要
- 使用 SSL 設定更新 nginx 設定檔(
/etc/nginx/sites-available/redash
)(請參閱下面的範例)。確保將憑證上傳到伺服器,並在新設定中正確設定路徑。 - 在您的安全群組中開啟 443 連接埠(如果使用 AWS 或 GCE)。
upstream redash_servers {
server 127.0.0.1:5000;
}
server {
listen 80;
# Allow accessing /ping without https. Useful when placing behind load balancer.
location /ping {
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;
proxy_pass http://redash_servers;
}
location / {
# Enforce SSL.
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
# Make sure to set paths to your certificate .pem and .key files.
ssl on;
ssl_certificate /path-to/cert.pem; # or crt
ssl_certificate_key /path-to/cert.key;
# As per the Mozilla SSL Configuration Generator (https://ssl-config.mozilla.org), using the Intermediate setting.
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:DHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers off;
access_log /var/log/nginx/redash.access.log;
gzip on;
gzip_types *;
gzip_proxied any;
location / {
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;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://redash_servers;
proxy_redirect off;
}
}
在 nginx 前使用其他代理/負載平衡器
如果您的設定在 Redash 的 nginx 前包含另一個代理/負載平衡器,您將需要在 nginx 設定中新增以下標頭,以確保它知道正在使用的正確協定
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;