Dean Christian Armada
Dean Christian Armada

Reputation: 7384

Nginx not listening to other ports only port 80

I have 3 apps:

What happens is only the port 80 is running others are just connecting

Here's my codes

port 80.conf

server {

    listen 80;
    server_name example1.com;
    charset utf-8;
    access_log /var/log/nginx/access.example1.log;
    error_log /var/log/nginx/error.example1.log;

    location /static {
        alias /usr/src/app/static;
    }
    location / {
        proxy_pass http://example1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

port8001.conf

server {

    listen 8001;
    server_name example2.com;
    charset utf-8;
    if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
        set $year $1;
        set $month $2;
        set $day $3;
    }
    access_log /usr/logs/nginx/example1/example2.$year-$month-$day.log;

    location / {
        root /usr/src/example2;
    }
    error_page  405     =200 $uri;
}

port 8002

server {

    listen 8002;
    server_name example3.com;
    charset utf-8;

    include /etc/nginx/www-allow/example3-allow.conf;
    deny all;

    if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
        set $year $1;
        set $month $2;
        set $day $3;
    } 
    access_log /usr/logs/nginx/example3/example3.$year-$month-$day.log;

    location / {
        root /usr/src/example3;
    }
}

The funny part here is that I tried making the port81.conf to listen on port 80 and making the listen on the port80.conf into port 8001 and this time my app in port81,conf worked..

So it just means that my server just doesn't allow to be accessed in other ports like example.com:8001

How can this be resolved?

Upvotes: 2

Views: 844

Answers (2)

jravenger4
jravenger4

Reputation: 163

On my case I'm trying to browse http://{Local machine IP Address}:8080, that is why the page is not shown. To my confusion I forgot that I need to get the IP Address of the Docker container.

Here is the docker command for that:

docker exec {docker container id} ipconfig

Then get the IP Address and browse it using this format: http://{Docker container IP Address}:8080

Upvotes: 0

Nick
Nick

Reputation: 31

Have you opened the firewall for ports 8001 and 8002?

Upvotes: 2

Related Questions