解决方法, NGINX 中 location ^~ / {
proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
proxy_set_header    Host              $http_host;
proxy_set_header    X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:2369;
|  |      1xratzh      2017-06-16 23:36:05 +08:00 via iPhone 没看懂?什么链接无法访问? | 
|      2AirSc OP @xratzh 在服务器上面搭了一个 Ghost,使用 localhost 的域名,然后利用 Nginx 反代之后,内容当然显示的还是 localhost 的,但是找不到地方把用户访问的 localhost 替换成域名 | 
|  |      4tayuo      2017-06-16 23:55:36 +08:00 via iPhone Ghost 1.0.0 推荐使用 Ghost-CLI 进行部署 可以自动生成配置文件 | 
|      5AirSc OP @tayuo 对,部署的时候填的 URL 不是 localhost 么?需要用 nginx 反代才可以给用户看。但是反代之后所有的链接都还是 localhost 的。 | 
|      6AirSc OP @tayuo 比如,我在 config.production.json "url"改成了我的域名,使用反代,反代 localhost:2369,就会导致 redirected you too many times. 的错误。 Nginx 里是这样配置的: location ^~ / { 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://127.0.0.1:2369; proxy_redirect off; } | 
|      7AirSc OP @tayuo 比如说: https://www.airscr.com/ Logo 处和分享的时候,url 都是 127.0.0.1 | 
|  |      8xratzh      2017-06-17 00:34:05 +08:00 via iPhone 你在 ghost 后台设置用户的主页信息试试? | 
|  |      12chinni      2017-06-17 01:09:25 +08:00 你需要给 nginx 编译一个 subs_filter 模块 替换下字符串 | 
|  |      13nirocfz      2017-06-17 01:41:09 +08:00 via Android 没配置 ghost 的 url 吧. 默认是不是没有 config.js, 有个 config.example.js | 
|  |      14GoBeyond      2017-06-17 05:58:26 +08:00 via Android 你配置文件有问题吧 | 
|  |      15indust      2017-06-17 07:34:07 +08:00 1.0 版的配置文件是 config.production.json | 
|      16AirSc OP | 
|      17AirSc OP @indust 在 0.x 的版本里,有个 production URL 可以使输出的链接自定义,但是在 1.0 里面的 config.production.json 却没有这个功能 | 
|  |      18tayuo      2017-06-17 09:49:49 +08:00 via iPhone 在用 Ghost-CLI 进行 ghost setup 的时候 第一项填写网址的时候填 http://domain 不需要填写 127.0.0.1:2368 | 
|  |      19nirocfz      2017-06-17 09:56:11 +08:00 via Android @AirSc 看看有什么配置选项,文件里没有,自己可以加上,url 这个配置是文档里的第一个配置项项啊。自己不告诉 ghost 生成的页面里 url 是什么,当然页面上不是域名。先生成了页面,再通过前面做反代的 nginx 修改页面内容,能起作用,并不合理 https://docs.ghost.org/v1.0.0/docs/configuring-ghost | 
|  |      20Hardrain      2017-06-17 14:55:56 +08:00 关于域名是 localhost 的问题: 检查一下 config.js 中的 url:'https://yourdomain.tld' 这个地方填的是不是你的域名而非 localhost | 
|  |      21Hardrain      2017-06-17 15:03:06 +08:00 @AirSc 关于这个重定向循环,并且你使用了 https,你需要让 Ghost(Node 后端知道浏览器在用 https 访问前端,也就是 Nginx) 前端(反代,Nginx,apache httpd...)需要向后端 Pass 一个 Request Header X-Forwarded-Proto:https For Nginx: server { listen 443 ssl http2; server_name yourdomain.tld; ssl on; location / { proxy_pass http://127.0.0.1:2369; proxy_set_header X-Forwarded-For 'https'; ......} } For Apache httpd <VirtualHost *:443> ServerName yourdomain.tld ProxyPass / http://127.0.0.1:2369/ ProxyPassReverse / http://127.0.0.1:2369/ ProxyAddHeaders On RequestHeader set X-Forwarded-Proto "https" ...... </VirtualHost> | 
|  |      22Hardrain      2017-06-17 15:16:22 +08:00 如果使用环境变量而非 fixed string 应该这么写 Nginx: proxy_set_header X-Forwarded-For $scheme; Apache httpd: RequestHeader set X-Forwarded-Proto "%{REQUEST_SCHEME}s" | 
|      23AirSc OP @Hardrain  location ^~ / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For 'https'; proxy_set_header X-NginX-Proxy true; proxy_pass http:/localhost:2369; proxy_redirect off; } 现在是这样写的,凡是他又会重定向到 http://localhost:2369 | 
|      24AirSc OP proxy_pass http:// 是这样的,上面少写了 |