yong ho
yong ho

Reputation: 4032

Nginx not working on port 80

I have a node.js server running on localhost:1337. I have made a nginx site file in sites_enabled. If I go to url admin.tvchatter.cn:1337, it is working, but if I go to url admin.tvchatter.cn, the page sitll shows "Welcome to nginx!". It seems the listen 80 is not working. the file contents are:

server {
    listen 80;
    server_name admin.tvchatter.cn;
    access_log /var/log/nginx/admin.tvchatter.cn.access.log;
    error_log /var/log/nginx/admin.tvchatter.cn.error.log;
    client_max_body_size 200m;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 16 64k;
    gzip_http_version 1.1;
    gzip_comp_level 6;
    gzip_types text/plain application/x-javascript text/javascript text/css application/xml;
    gzip_vary on;

    location /{
        proxy_pass http://127.0.0.1:1337;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Upvotes: 3

Views: 4964

Answers (3)

Guillaume Escarieux
Guillaume Escarieux

Reputation: 31

In my case, the proxy was working only if I was using another port like 90

In fact, I was importing all the conf files like this in my /etc/nginx/nginx.conf:

include /etc/nginx/conf.d/*.conf;

But my file was conflicting with existing ones in this folder. I changed it to this and it worked:

include /etc/nginx/conf.d/frontend.conf;

Upvotes: 0

Thanh Nguyen Van
Thanh Nguyen Van

Reputation: 11752

Check all files in /etc/nginx/sites-enabled/ to find:

proxy_pass http://example.com:8080;

to see nginx use proxy_pass to other port.

if yes, disable it.

Upvotes: 1

cn0047
cn0047

Reputation: 17051

You need to specify root clause, by default it contain value: /var/www/html/index.html hence you see default nginx page. My config looks like:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

Upvotes: 1

Related Questions