Nginx reachable from localhost not outside of network, other programmes are reachable

I am running Ubuntu 24.04 on a virtual machine. I am trying to setup nginx but can’t get seem to reach it from outside of the local network.

This is my nginx.conf

user root;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        server {
                listen 80;
                location / {
                        default_type text/html;
                        return 200 "testn";
                        # proxy_pass http://localhost:8005/;
                }
          }
   }

While running a docker compose project with open ports they are reachable from the public ip. The nginx configuration is reachable from localhost: doing curl http://localhost:80 returns the expected output. However reaching nginx from the public ip adress doesn’t seem to work.

Nginx is listening correctly if inspected with netstat:

~# sudo netstat -tanpl|grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      140762/nginx: maste

The port 80 does not show up on IPtables:

~# iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-N DOCKER
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.22.0.0/16 ! -o br-ac050cf1bd25 -j MASQUERADE
-A POSTROUTING -s 172.21.0.0/16 ! -o br-411d5766abb2 -j MASQUERADE
-A POSTROUTING -s 172.20.0.0/16 ! -o br-a43c6c8e276e -j MASQUERADE
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A POSTROUTING -s 172.20.0.3/32 -d 172.20.0.3/32 -p tcp -m tcp --dport 8005 -j MASQUERADE
-A POSTROUTING -s 172.20.0.5/32 -d 172.20.0.5/32 -p tcp -m tcp --dport 8003 -j MASQUERADE
-A POSTROUTING -s 172.20.0.4/32 -d 172.20.0.4/32 -p tcp -m tcp --dport 8004 -j MASQUERADE
-A POSTROUTING -s 172.20.0.6/32 -d 172.20.0.6/32 -p tcp -m tcp --dport 9600 -j MASQUERADE
-A POSTROUTING -s 172.20.0.6/32 -d 172.20.0.6/32 -p tcp -m tcp --dport 9200 -j MASQUERADE
-A POSTROUTING -s 172.20.0.7/32 -d 172.20.0.7/32 -p tcp -m tcp --dport 9600 -j MASQUERADE
-A POSTROUTING -s 172.20.0.8/32 -d 172.20.0.8/32 -p tcp -m tcp --dport 8001 -j MASQUERADE
-A POSTROUTING -s 172.20.0.9/32 -d 172.20.0.9/32 -p tcp -m tcp --dport 8002 -j MASQUERADE
-A POSTROUTING -s 172.20.0.10/32 -d 172.20.0.10/32 -p tcp -m tcp --dport 5601 -j MASQUERADE
-A POSTROUTING -s 172.20.0.11/32 -d 172.20.0.11/32 -p tcp -m tcp --dport 8006 -j MASQUERADE
-A POSTROUTING -s 172.20.0.7/32 -d 172.20.0.7/32 -p tcp -m tcp --dport 9200 -j MASQUERADE
-A DOCKER -i br-ac050cf1bd25 -j RETURN
-A DOCKER -i br-411d5766abb2 -j RETURN
-A DOCKER -i br-a43c6c8e276e -j RETURN
-A DOCKER -i docker0 -j RETURN
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8005 -j DNAT --to-destination 172.20.0.3:8005
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8003 -j DNAT --to-destination 172.20.0.5:8003
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8004 -j DNAT --to-destination 172.20.0.4:8004
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9600 -j DNAT --to-destination 172.20.0.6:9600
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9200 -j DNAT --to-destination 172.20.0.6:9200
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9601 -j DNAT --to-destination 172.20.0.7:9600
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8001 -j DNAT --to-destination 172.20.0.8:8001
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8002 -j DNAT --to-destination 172.20.0.9:8002
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 5601 -j DNAT --to-destination 172.20.0.10:5601
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8006 -j DNAT --to-destination 172.20.0.11:8006
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9202 -j DNAT --to-destination 172.20.0.7:9200

Does anyboy have any idea what is going on here?

I checked the status of ufw and it was inactive.While running a docker compose project with open ports they are reachable from the public ip. The nginx configuration is reachable from localhost: doing curl http://localhost:80 return the expected output. However reaching nginx from the public ip adress doesn’t seem to work.

Nginx is listening correctly if inspected with netstat:

~# sudo netstat -tanpl|grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      140762/nginx: maste

The port 80 does not show up on IPtables:

~# iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-N DOCKER
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.22.0.0/16 ! -o br-ac050cf1bd25 -j MASQUERADE
-A POSTROUTING -s 172.21.0.0/16 ! -o br-411d5766abb2 -j MASQUERADE
-A POSTROUTING -s 172.20.0.0/16 ! -o br-a43c6c8e276e -j MASQUERADE
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A POSTROUTING -s 172.20.0.3/32 -d 172.20.0.3/32 -p tcp -m tcp --dport 8005 -j MASQUERADE
-A POSTROUTING -s 172.20.0.5/32 -d 172.20.0.5/32 -p tcp -m tcp --dport 8003 -j MASQUERADE
-A POSTROUTING -s 172.20.0.4/32 -d 172.20.0.4/32 -p tcp -m tcp --dport 8004 -j MASQUERADE
-A POSTROUTING -s 172.20.0.6/32 -d 172.20.0.6/32 -p tcp -m tcp --dport 9600 -j MASQUERADE
-A POSTROUTING -s 172.20.0.6/32 -d 172.20.0.6/32 -p tcp -m tcp --dport 9200 -j MASQUERADE
-A POSTROUTING -s 172.20.0.7/32 -d 172.20.0.7/32 -p tcp -m tcp --dport 9600 -j MASQUERADE
-A POSTROUTING -s 172.20.0.8/32 -d 172.20.0.8/32 -p tcp -m tcp --dport 8001 -j MASQUERADE
-A POSTROUTING -s 172.20.0.9/32 -d 172.20.0.9/32 -p tcp -m tcp --dport 8002 -j MASQUERADE
-A POSTROUTING -s 172.20.0.10/32 -d 172.20.0.10/32 -p tcp -m tcp --dport 5601 -j MASQUERADE
-A POSTROUTING -s 172.20.0.11/32 -d 172.20.0.11/32 -p tcp -m tcp --dport 8006 -j MASQUERADE
-A POSTROUTING -s 172.20.0.7/32 -d 172.20.0.7/32 -p tcp -m tcp --dport 9200 -j MASQUERADE
-A DOCKER -i br-ac050cf1bd25 -j RETURN
-A DOCKER -i br-411d5766abb2 -j RETURN
-A DOCKER -i br-a43c6c8e276e -j RETURN
-A DOCKER -i docker0 -j RETURN
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8005 -j DNAT --to-destination 172.20.0.3:8005
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8003 -j DNAT --to-destination 172.20.0.5:8003
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8004 -j DNAT --to-destination 172.20.0.4:8004
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9600 -j DNAT --to-destination 172.20.0.6:9600
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9200 -j DNAT --to-destination 172.20.0.6:9200
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9601 -j DNAT --to-destination 172.20.0.7:9600
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8001 -j DNAT --to-destination 172.20.0.8:8001
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8002 -j DNAT --to-destination 172.20.0.9:8002
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 5601 -j DNAT --to-destination 172.20.0.10:5601
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 8006 -j DNAT --to-destination 172.20.0.11:8006
-A DOCKER ! -i br-a43c6c8e276e -p tcp -m tcp --dport 9202 -j DNAT --to-destination 172.20.0.7:9200

Does anyboy have any idea what is going on here?

I checked and ufw is inactive.

The access log only shows the succesfull requests from localhost, the error log does not contain any errors.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật