【问题标题】:nginx: index.js" is forbidden (13: Permission denied)nginx: index.js" 被禁止 (13: Permission denied)
【发布时间】:2018-08-01 02:10:33
【问题描述】:

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

我的浏览器显示:403 Forbidden nginx/1.10.3 (Ubuntu)

如果我运行:

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

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

这是我在启用网站时所拥有的:

有什么问题?

编辑网站后启用

如果我运行:

systemctl status nginx.service

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

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

我得到: 连接到上游时 connect() 失败(111:连接被拒绝)

【问题讨论】:

    标签: node.js ubuntu nginx ssh digital-ocean


    【解决方案1】:

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

    相反,在后台运行带有 node.js 的index.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

    【讨论】:

    • root@ubuntu-s-1vcpu-1gb-fra1-01:/etc/nginx/sites-enabled# service nginx start nginx.service 的作业失败,因为控制进程以错误代码退出。详见“systemctl status nginx.service”和“journalctl -xe”。
    • 你的 nginx 配置有问题,systemctl status nginx.service 说什么?
    • 文本太长,无法发表评论,所以我编辑了最初的帖子
    • (111: Connection refused) while connecting to upstream 表示您的http://localhost:8080 无法访问。确保您的 node.js 服务在端口 8080 中正确服务,或者将地址更改为它所服务的正确端口。可以先通过curl命令检查node.js进程是否正常运行
    猜你喜欢
    • 2015-10-22
    • 2016-06-06
    • 2021-11-08
    • 1970-01-01
    • 2021-01-31
    • 2018-07-21
    • 2018-11-02
    • 2016-03-26
    • 2019-12-17
    相关资源
    最近更新 更多