在使用nginx的一台服务器上使用两个域来建立两个幽灵博客

时间:2018-12-05 10:57:59

标签: nginx ghost-blog

设置是:2个不同的域,在一台nginx ubuntu 18.04 LTS服务器上2个单独的GHOST博客安装

现在域A和域B都指向GHOST博客A。我希望域A指向GHOST BLOG A,域B指向GHOST BLOG B。

两个域都通过DNS指向同一服务器IP。

请参阅以下有关Ghost的config config.json文件:

博客A

{
  "url": "https://til.technology",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "dbu",
      "password": "password",
      "database": "db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/html/til.technology/content"
  },
  "bootstrap-socket": {
    "port": 8000,
    "host": "localhost"
  }
}

博客B

{
  "url": "https://losing.ink",
  "server": {
    "port": 2370,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "dbu2",
      "password": "pw2",
      "database": "db2"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/html/losing.ink/content"
  },
  "bootstrap-socket": {
    "port": 8000,
    "host": "localhost"
  }
}

nginx服务器阻止如下:

博客A

server {
    listen 80;
    listen [::]:80;

    server_name til.technology www.til.technology;
    root /var/www/html/til.technology/system/nginx-root;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

博客B

server {
    listen 80;
    listen [::]:80;

    server_name losing.ink www.losing.ink;
    root /var/www/html/losing.ink/system/nginx-root;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2370;
        proxy_redirect off;

    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

1 个答案:

答案 0 :(得分:0)

因此,事实证明我所做的一切基本上都正确,但是似乎Ghost的CLi安装程序中存在错误,并且他们已在几个小时前发布的最新更新中解决了该问题。谢谢