簡體   English   中英

同時使用HTTP和HTTPS設置Ghost + Nginx時出現ERR_TOO_MANY_REDIRECTS

[英]ERR_TOO_MANY_REDIRECTS while setting up Ghost + Nginx with both HTTP and HTTPS

我正在使用Nginx(1.8.1)在VPS中部署Ghost(0.7.6)。 為了確保儀表板和登錄頁面的安全,在訪問此類頁面(例如/ghost頁面)時,我強制所有請求使用HTTPS。 但是,對於對其他任何頁面的任何請求(例如訪問Ghost博客本身),我想強制其使用HTTP。 Ghost正在收聽127.0.0.1:2368

奇怪的是,結果並沒有達到我的預期:每次訪問博客(例如url為ab )時,它都表明我的站點具有ERR_TOO_MANY_REDIRECTS並且它在http://abhttps://ab之間重定向(或在http://ab/signinhttps://ab/signin )。 但是,當我訪問管理儀表盤( https://ab/ghosthttp://ab/ghost )時,它按預期方式工作(無錯誤,正確重定向以使用HTTPS)。

有什么幫助嗎?

我的Nginx配置:

# Configuration for http://a.b
server {
    listen 80;
    server_name a.b;
    location ^~ /ghost { # /ghost should be accessed securely
        return 301 https://$host$request_uri;
    }
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:2368;
    }
}

# Configuration for http://a.b
server {
    listen 443 ssl;
    server_name a.b;
    ssl_certificate ...;
    ssl_certificate_key ...;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers '...';

    location ^~ /ghost { # /ghost should be accessed securely
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:2368;
    }
    location / { # Force to use HTTP
        return 301 http://$host$request_uri;
    }
}

任何形式的幫助將不勝感激:')

https://github.com/TryGhost/Ghost/issues/2796

location ^~ /ghost { # /ghost should be accessed securely
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header HOST $host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:2368;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM