ssl - 当 ghost 安装在子目录中时,如何强制 Ghost 的管理页面成为 SSL 服务器?

标签 ssl nginx reverse-proxy ghost-blog

我使用 Ghost 作为博客平台,使用 nginx 作为 ghost 的反向代理,详见文档。 Ghost 安装在一个子目录中,并在域 http://example.com/blog 上提供服务而静态网站是通过 example.com 提供的

我已经在我的服务器上设置了 SSL,并希望通过 SSL 为 ghost 登录页面 (example.com/blog/ghost) 提供服务,同时通过普通 HTTP 为其余页面提供服务。但是,如果我使用 forceAdminSSL:true 并尝试转到 http://example.com/blog/ghost,它应该会自动将我重定向到 https://example.com/blog/ghost。相反,我被重定向到 https://example.com/ghost 并以 404 错误结束。我发现唯一可行的解​​决方法是使用 foreAdminSSL:{redirect:false} 这很笨拙,因为我必须在地址栏中手动键入 https 而不是 http。

当 ghost 安装在子目录中时,我如何通过 ssl 服务器 Ghost 管理面板?我想这与 nginx 中的配置有关。

我的 nginx 配置 block

    server {
     listen       80;
     listen 443 ;
     server_name  *.example.com;
     server_name  example.com;
     ssl on;
     ssl_certificate /etc/nginx/ssl/certificate.crt;
     ssl_certificate_key /etc/nginx/ssl/key.key;

     location ^~/blog {
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header Host $host;
             proxy_set_header X-NginX-Proxy true;
             proxy_set_header X-Forwarded-Proto $scheme;
             proxy_pass http://127.0.0.1:2786;
             proxy_redirect off;
     }


    location / {
            root "/home/ubuntu/somedirectory/";
            index index.html;
    }

最佳答案

我认为您在正确设置 Ghost 时没有输入配置 URL。

您可以通过运行以下命令来执行此操作:

ghost 配置 URL https://my-domain.com/blog/

幽灵重启

如果这不能解决问题,您可以在我的博客上查看解决此问题的详细教程 here

关于ssl - 当 ghost 安装在子目录中时,如何强制 Ghost 的管理页面成为 SSL 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27658522/

相关文章:

c - 基于 epoll 的非阻塞 ssl_read() 陷入循环

node.js - Nginx 反向代理不适用于域名

node.js - 如何允许客户在服务网站上为自己的页面设置自定义域?

docker - Traefik仪表板仅在http端口上

java - 具有特定协议(protocol)版本的 SSL 连接

windows - curl : (1) Protocol https not supported or disabled in libcurl [windows XP]

javascript - 单元测试时如何模拟代理?

linux - NginX 作为多个子域的 HTTPS 反向代理?

reactjs - Nginx 反向代理和多个 React 应用程序

mysql - "Error establishing a database connection"在 Kubernetes 上使用 Wordpress、MySQL、Nginx