配置Nginx在Centos 7上运行Nodejs

问题描述 投票:1回答:1

我正在我的centos 7上安装nodejs和nginx。我的应用程序在my_domain上工作正常:3000但在my_domain.com上有错误消息您正在寻找的页面暂时不可用。请稍后再试。这是我的nginx.conf。请帮助nginx.conf

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  digitaloceantwo.25o2.in;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        proxy_pass http://digitaloceantwo.25o2.in: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;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

hello.js

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8080,'159.65.150.176');
console.log('Server running at http://digitaloceantwo.25o2.in:8080/');
node.js nginx centos7 droplet
1个回答
1
投票

我有类似的问题让Fedora 20,Nginx,Node.js和Ghost(博客)工作。事实证明我的问题是由于SELinux。

这应该解决问题:

setsebool -P httpd_can_network_connect 1详细信息我检查了SELinux日志中的错误:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied并发现运行以下命令修复了我的问题:

sudo cat /var/log/audit/audit.log | grep nginx | grep否认| audit2allow -M mynginx sudo semodule -i mynginx.pp参考文献:

http://blog.frag-gustav.de/2013/07/21/nginx-selinux-me-mad/

https://wiki.gentoo.org/wiki/SELinux/Tutorials/Where_to_find_SELinux_permission_denial_details

http://wiki.gentoo.org/wiki/SELinux/Tutorials/Managing_network_port_labels

http://www.linuxproblems.org/wiki/Selinux

© www.soinside.com 2019 - 2024. All rights reserved.