2013-11-15 35 views
0

我有我的linode与nginx和客运跑道应用程序运行。现在我创建了一个名为blog.domain.com的新域名我已经使用ghost blogger 创建了一个博客我无法理解如何将我的博客域指向幽灵博客。我需要在ghost博客中更改nginx配置或config.js如何将域名指向鬼博客

这里是我的config.js

var path = require('path'), 
    config; 

config = { 
    development: { 
     url: 'http://my-ghost-blog.com', 

`` 

     database: { 
      client: 'sqlite3', 
      connection: { 
       filename: path.join(__dirname, '/content/data/ghost-dev.db') 
      }, 
      debug: false 
     }, 
     server: { 
      port: '2368' 
     } 
    }, 
    production: { 
     url: 'http://my-ghost-blog.com', 
     mail: {}, 
     database: { 
      client: 'sqlite3', 
      connection: { 
       filename: path.join(__dirname, '/content/data/ghost.db') 
      }, 
      debug: false 
     }, 
     server: { 
      host: '127.0.0.1', 
      // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` 
      port: '2368' 
     } 
    }, 
    testing: { 
     url: 'http://127.0.0.1:2369', 
     database: { 
      client: 'sqlite3', 
      connection: { 
       filename: path.join(__dirname, '/content/data/ghost-test.db') 
      } 
     }, 
     server: { 
      host: '127.0.0.1', 
      port: '2369' 
     } 
    }, 
    travis: { 
     url: 'http://127.0.0.1:2368', 
     database: { 
      client: 'sqlite3', 
      connection: { 
       filename: path.join(__dirname, '/content/data/ghost-travis.db') 
      } 
     }, 
     server: { 
      host: '127.0.0.1', 
      port: '2368' 
     } 
    } 
}; 
module.exports = config; 

回答

1

要启用您的博客自定义域,你需要改变鬼和Nginx的配置。

首先,您必须将config.js中的url:值更改为您的域名。

development: { 
    url: 'http://blog.domain.com', 
... 
production: { 
    url: 'http://blog.domain.com', 

其次,nginx需要传递请求到博客。配置应该在/etc/nginx/

server { 

    listen 80; 
    listen [::]:80; 

    server_name blog.domain.com; 

    location/{ 
     proxy_pass   http://localhost:2368/; 
     proxy_set_header Host $host; 
     proxy_buffering  off; 
    } 
} 

更改配置后Ghost和nginx需要重新启动。

+0

你能否清除一个疑问。上述配置文件中主机和端口的用途是什么? – overflow

+0

在config.js中存储配置。 'host:'=服务器的IP或主机名。 'port:'=应用程序正在侦听的端口。然后将Nginx用作前端服务器并将所有请求重定向到Ghost。 – sebgie

+0

config.js中的'host' /'port'是node.js应用程序要侦听请求的值。 – sebgie

2

可以结帐我如何here但其基本思想是:你只需要

如果您目前有一个Nginx的网络服务器上运行的网站,你有兴趣在区域上的安装Ghost来增加一个小改为你的nginx的default.conf。

您的网站的Nginx默认位置是/ usr/share/nginx/html,所以我们将坚持这一点。我们将在/usr/share/nginx/html/example.com目录中创建主要网站,并在/usr/share/nginx/html/blog.example.com中创建Ghost博客。

要告诉Nginx我们的新博客,我们需要编辑nginx的default.conf文件。该文件默认位于/etc/nginx/conf.d/default.conf。编辑该文件:

sudo vi /etc/nginx/conf.d/default.conf

现在在文件的最底部在下面添加(该服务器名称更改为您的网站):

#Following section for blog.example.com 
server { 
    listen 80; 
    server_name blog.example.com; 

    location/{ 
      proxy_pass http://127.0.0.1:2368/; 
      proxy_set_header Host $host; 
      proxy_buffering off; 

    } 
} 

现在只需重启nginx的,你的变化将采取影响。

sudo service nginx restart