1

I'm installing nodejs and nginx on my centos 7. My app works fine on my_domain:3000 but error on my_domain.com with message The page you are looking for is temporarily unavailable. Please try again later. This is my nginx.conf. Pls help 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/');
Akshay Pitale
  • 96
  • 1
  • 8
  • Are you able to access nodejs app from Nginx server, you may test via `curl http://digitaloceantwo.25o2.in:8080` – Arif Khan Sep 04 '18 at 11:21

1 Answers1

3

I had a similar issue getting Fedora 20, Nginx, Node.js, and Ghost (blog) to work. It turns out my issue was due to SELinux.

This should solve the problem:

setsebool -P httpd_can_network_connect 1 Details I checked for errors in the SELinux logs:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied And found that running the following commands fixed my issue:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx sudo semodule -i mynginx.pp References:

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

Akshay Pitale
  • 96
  • 1
  • 8