1

我将我的 Ghost 博客托管在 EC2 实例上,并尝试将 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 用来确定流量是否存在的请求中删除一些标头,httphttps我无法确认这一点。

这是我的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"

任何想法可能导致此问题或如何解决?建议表示赞赏。

4

0 回答 0