nginx: index.js" is forbidden (13: Permission denied)

nginx: index.js" is forbidden (13: Permission denied)

我在配置我的 ubuntu 服务器时做错了事

我的浏览器显示:403 禁止访问 nginx/1.10.3 (Ubuntu)

如果我 运行 :

tail -f /var/log/nginx/error.log

我得到: ".../root/curlist/index.js" 被禁止(13:权限被拒绝)..."

这是我在启用站点中的内容:

有什么问题?

ps 编辑站点后启用

如果我运行:

systemctl status nginx.service

我得到: 但是如果我 运行 :

tail -f /var/log/nginx/error.log

我得到: connect() 在连接到 upstream

时失败(111:连接被拒绝)

你不应该在nginx中直接运行 index.js

相反,运行 index.js 在后台使用 node.js,然后设置 nginx 转发到它的侦听端口。

例如

location / {
    proxy_pass http://localhost:8080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

阅读 tutorial of node.js + nginx configuration here