让 Ghost 通过 Sockets 运行
本文最后更新于 3006 天前,其中的信息可能已经有所发展或是发生改变。

如果你时用 Nginx 代理 Ghost 的话,我们可以用让 Server 用 Unix Sockets 方式跑,就不用设置代理端口了。

Sockets 方式

编辑 config.js 文件

server: {
    host: '127.0.0.1',
    port: '2368'
}

替换为

server: {
    socket: {
        path: '/data/wwwroot/mf8/socket.sock',
        permissions: '0666'
   }
}

这里的 /data/wwwroot/mf8 就是你的 Ghost 物理路径, permissions: '0666' 是默认权限,不加这个也是 0666,如果需要修改权限,则可以自己添加。

重启 Ghost 后,目录下会出现 socket.sock 文件。具体可以参看官方说明:http://support.ghost.org/config/#server

配置 Nginx

这里的话,代理便要换成 socket 了。

     location / {
         proxy_pass /data/wwwroot/mf8/socket.sock;
         proxy_set_header Host $http_host;
         proxy_set_header User-Agent $http_user_agent;
         proxy_set_header X-Real-IP $remote_addr;
  }

重启即可。

上一篇
下一篇