我的 Ghost 应用程序收到 502 bad gateway 错误。 我在互联网上进行了研究,但没有找到答案。
我的 Ghost config.js:
var path = require('path'),
config;
config = {
production: {
url: 'http://supetar.italoborg.es',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
// Host to be passed to node's `net.Server#listen()`
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'
}
}
}
我的 Nginx supetar.italoborg.es 文件:
server {
listen 0.0.0.0:80;
server_name supetar.italoborg.es;
root /home/italo/www/supetar.italoborg.es/html;
index index.html index.htm index.js;
access_log /var/log/nginx/supetar.italoborg.es.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
我创建了指向启用站点的文件夹的符号链接(symbolic link):
lrwxrwxrwx 1 root root 47 Dec 16 12:10 supetar.italoborg.es -> /etc/nginx/sites-available/supetar.italoborg.es
我正在使用 PM2 启动 Ghost APP:
pm2 start index.js
当我尝试使用以下方式启动 Ghost APP 时:
npm start
我可以看到博客,但是当我尝试使用 pm2 时,我遇到了错误的网关。
我正在使用:
Ubunt 14.04 64 位
Node v0.10.13
Npm 2.1.12
谢谢!
最佳答案
在 Digital Ocean Ubuntu 实例中升级 Ghost 后,我遇到了同样的问题。
cd /var/www/ghost #or your custom ghost dir
ghost ls #lists your ghost configuration
确保 Ghost 的配置文件中配置的端口号与 Ghost 站点的 nginx 配置文件中的proxy_pass匹配。
检查端口号
/var/www/ghost/config.production.json
与 nginx 配置文件中的 proxy_pass 端口匹配。
/var/www/ghost/system/files/<yourDomainName>.<extension>.conf
/var/www/ghost/system/files/<yourDomainName>.<extension>-ssl.conf
就我而言,我必须将 nginx 配置文件中的 2368 更改为 2369 才能解决该问题。
进行更改后,请确保重新启动 Ghost 和 nginx。
# restart your ghost site
cd /var/www/ghost/
ghost restart
# restart nginx
sudo systemctl restart nginx
希望这对某人有帮助。
关于node.js - Ghost 博客与 Nginx 网关故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27510826/