Environment: Nginx (with SSL)+Docker+Ghost
The Docker container runtime is configured with an environment variable -e URL=xxx
Nginx configuration:
server {
listen 443 ssl http2;
ssl on;
server_name xxxxx.xxx;
ssl_certificate /etc/nginx/ssl/*.xxxxx.xxx.cer;
ssl_certificate_key /etc/nginx/ssl/*.xxxxx.xxx.key;
add_header Strict-Transport-Security max-age=31536000;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:80xx;
}
}
server {
listen 80;
server_name xxxxx.xxx;
add_header Strict-Transport-Security max-age=31536000;
return 301 https://xxxxx.xxx$request_uri;
}
Phenomena: Chrome prompt redirects too many times, closing Docker container to display 502 Bad Gateway
No additional environment variables are normal.
Recently in the buildingGhostWhen blogging, because of the use of
Nginx
Not under my control, so I also encountered this use.https
The problem of “too many redirections” (url changed tohttp
There is no problem); After searching, we got the answer:X-Forwarded-Proto
ForSSL
Especially important. Therefore, when using Nginx or Apache as a proxy, it needs to be configured. If you use Nginx, you can configure it as follows: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://127.0.0.1:2368; }
Reference: