我在EC2实例上托管我的Ghost博客,并尝试将cloudfront置于博客前面,但遇到了重定向错误。
博客在没有云端的情况下工作得非常好,但一旦添加,问题就出现了。我认为这可能与我的SSL配置有关。我的Nginx
文件已设置为通过http
upstream app_yourdomain {
server 127.0.0.1:2368;
keepalive 8;
}
# the nginx server instance
server {
listen 0.0.0.0:80;
server_name mysite.com mysite;
access_log /var/log/nginx/blog.log;
location /blog/content/images {
alias /var/www/ghost/content/images;
}
location /blog/assets {
alias /var/www/ghost/content/themes/pluto/assets;
}
location ~ ^/blog/(?:ghost|signout) {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://app_yourdomain;
add_header Cache-Control "no-cache, max-age=0, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0";
}
# pass the request to the node.js server with the correct headers
# and much more can be added, see nginx config options
location /blog/ghost {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_yourdomain/;
# proxy_redirect off;
}
location / {
proxy_cache STATIC;
proxy_cache_valid 200 60m;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://app_yourdomain/;
expires 60m;
add_header X-Cache-Status $upstream_cache_status;
}
}
但网站本身正在SSL
上投放。当网站不在cloudfront
之后,这不是问题,但一旦发生错误,就不会出现问题。我认为可能会发生的是cloudfront
正在从ghost请求用于确定流量是http
还是https
的请求中删除一些标题,但我还没有能够确认一下。
这是我nginx
日志中的内容:
46.100.228.227 - - [17/Oct/2015:23:43:59 +0000] "GET /blog/ghost HTTP/1.0" 303 55 "-" "Amazon CloudFront"
46.100.228.227 - - [17/Oct/2015:23:43:59 +0000] "GET /blog/ghost/ HTTP/1.0" 301 66 "-" "Amazon CloudFront"
46.100.228.227 - - [17/Oct/2015:23:44:00 +0000] "GET /blog/ghost/ HTTP/1.0" 301 66 "-" "Amazon CloudFront"
46.100.228.227 - - [17/Oct/2015:23:44:00 +0000] "GET /blog/ghost/ HTTP/1.0" 301 66 "-" "Amazon CloudFront"
46.100.228.227 - - [17/Oct/2015:23:44:00 +0000] "GET /blog/ghost/ HTTP/1.0" 301 66 "-" "Amazon CloudFront"
46.100.228.227 - - [17/Oct/2015:23:44:00 +0000] "GET /blog/ghost/ HTTP/1.0" 301 66 "-" "Amazon CloudFront"
46.100.228.227 - - [17/Oct/2015:23:44:00 +0000] "GET /blog/ghost/ HTTP/1.0" 301 66 "-" "Amazon CloudFront"
46.100.228.227 - - [17/Oct/2015:23:44:00 +0000] "GET /blog/ghost/ HTTP/1.0" 301 66 "-" "Amazon CloudFront"
任何想法可能导致此问题或如何解决?建议表示赞赏。