0
votes

I'm trying to use nginx to setup a simple node.js server, I'm running the server in background on port 4000, my nginx config file is

server {
  listen 80;
  listen [::]:80;
  server_name 52.53.196.173;
  location / {
    include /etc/nginx/proxy_params;
    proxy_pass http://127.0.0.1:4000;
  }
}

I saved it in /etc/nginx/sites-available and also symlinked it to sites-enabled, the nginx.conf file has the include line already to load files from sites-enabled, then i restarted the service using sudo service nginx restart I tried going to 52.53.196.173 and it refuses to connect, however going to 52.53.196.173:4000 with port 4000 it is working, but I'm trying to make it listen on port 80 with nginx, i tried putting my .ml domain as server_name and no luck, and i have the IP 52.53.196.173 as the A record in the domain dns settings, and I'm doing this on an AWS EC2 Instance Ubuntu Server 16.04, i even tried the full ec2 public dns url no luck, any ideas?

Edit: I solved it by moving the file directly in sites-enabled instead of a symlink

3

3 Answers

2
votes

There is few possible things. First of all you need to verify that nginx server is running & listening on port 80. you can check the listening ports using the following command.

netstat -tunlp

Then you need to check your server firewall & also the selinux policies. ( OR disable selinux for test )

Then you need to verify that AWS security group configured to access the http/https connections on port 80.

PS : Outputs from the following command & configurations will be helpful for troubleshooting.

netstat -tunlp
sestatus
iptables -L

* AWS Security Group Rules
* Nginx configurations ( including main configuration if changed )

P.S : OP fixed the problem by moving the config file directly into site-enabled directory. maybe, reefer the comments for more info if you are having the same issue.

0
votes

Most probably port 80 might not be open in your security group or nginx is not running to accept the connections. Please post the nginx status and check the security group

0
votes

check belows:

  1. in security group, add Http (80) and Https (443) in inbound section with 0.0.0.0 ip as follow:

for 80 :

enter image description here

for 443 :

enter image description here

  1. in Network ACL, allow inbound on http and https. outbound set custom TCP role as follow:

inbound roles:

enter image description here

outbound roles:

enter image description here

  1. assign a elastic ip on ec2 instance, listen to this ip for public.