如何使用Nginx在子目录中安装Ghost? 获取404

问题描述

我是使用反向代理或管理技术基础结构的初学者。我在服务器上安装了主应用程序(react + nginx),并且试图将Ghost与主应用程序安装在同一服务器上的子文件夹https://tinymentions.io/blog上。

不幸的是,我无法成功配置Nginx来正确服务我的Ghost博客。 当我访问ttps://tinymentions.io/blog URL时,出现错误消息:“未找到HTTP / 1.1 404”

我搜索了Ghost论坛,Stack Overflow以及整个Google,尝试了不同的方法,但不幸的是,我仍然无法为该问题提供解决方案。每次尝试一种新方法时,我都会用sudo service nginx restart重新启动nginx,但是没有运气。

对此我将不胜感激。如果我不能正确地解释自己和/或需要更多信息,请告诉我。

-您的网址是什么?

我的主应用程序位于https://tinymentions.io/

-幽灵URL

https://tinymentions.io/blog

-您正在使用哪个版本的Ghost?

Ghost-CLI版本:1.15.0 幽灵版:3.35.5

-什么配置?

这是我的NGINX配置文件:

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name tinymentions.io www.tinymentions.io;

    client_max_body_size 4G;

    root /var/www/tiny-mentions/build;
    index index.html;

    location / {
        try_files $uri $uri/ @proxy_to_app;
    }

    location /blog {
        proxy_http_version 1.1;
        proxy_set_header Update &http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_pass http://localhost:2368;
    }

    location @proxy_to_app {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header Host $http_host;
      proxy_connect_timeout 25000s;
      proxy_read_timeout 25000;

      if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain; charset=utf-8';
        add_header 'Content-Length' 0;
        return 204;
     }

     if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET,Range';
        add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
     }

     if ($request_method = 'GET') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET,Content-Range';
     }

      proxy_redirect off;
      proxy_pass http://localhost:5000;
    }

    ssl_certificate /etc/letsencrypt/live/tinymentions.io/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/tinymentions.io/privkey.pem; # managed by Certbot

}

server {
    if ($host = www.tinymentions.io) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = tinymentions.io) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    listen [::]:80;

    server_name tinymentions.io www.tinymentions.io;

    return 301 https://$server_name$request_uri;

}

以下是我的config.production.json文件:

{
  "url": "http://tinymentions.io/blog","server": {
    "port": 2368,"host": "127.0.0.1"
  },"database": {
    "client": "mysql","connection": {
      "host": "localhost","user": "hidden","password": "hidden","database": "hidden"
    }
  },"mail": {
    "transport": "Direct"
  },"logging": {
    "transports": [
      "file","stdout"
    ]
  },"process": "systemd","paths": {
    "contentPath": "/var/www/ghost/content"
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)