Article 6MNHT Why does Nginx look for the default path instead of containers?

Why does Nginx look for the default path instead of containers?

by
Jason.nix
from LinuxQuestions.org on (#6MNHT)
Hello,
I have two containers running on ports 3000 and 3001:
Code:# ss -tupln
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp LISTEN 0 4096 0.0.0.0:80 0.0.0.0:* users:(("docker-proxy",pid=88600,fd=4))
tcp LISTEN 0 4096 0.0.0.0:3000 0.0.0.0:* users:(("docker-proxy",pid=87578,fd=4))
tcp LISTEN 0 4096 0.0.0.0:3001 0.0.0.0:* users:(("docker-proxy",pid=87600,fd=4))
tcp LISTEN 0 4096 127.0.0.1:35751 0.0.0.0:* users:(("obfs4proxy",pid=538,fd=3))
tcp LISTEN 0 4096 [::]:80 [::]:* users:(("docker-proxy",pid=88606,fd=4))
tcp LISTEN 0 4096 [::]:3000 [::]:* users:(("docker-proxy",pid=87585,fd=4))
tcp LISTEN 0 4096 [::]:3001 [::]:* users:(("docker-proxy",pid=87608,fd=4))Nginx configuration is as follows:
Code:server {
listen 80;
server_name localhost.comm;
error_log /var/log/nginx/error.system-default.log;
access_log /var/log/nginx/access.system-default.log;

location node1.localhost.comm {
proxy_pass http://Node1:3000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}

location node2.localhost.comm {
proxy_pass http://Node2:3001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}The /etc/hosts file is as follows:
Code:127.0.0.1 node1.localhost.comm
127.0.0.1 node2.localhost.commBut I can't see any of the containers:
Code:# curl node1.localhost.comm
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.25.4</center>
</body>
</html>The Nginx log is as follows:
Code:2024/05/08 14:14:58 [error] 28#28: *1 "/etc/nginx/html/index.html" is not found (2: No such file or directory), client: 192.168.32.1, server: localhost.comm, request: "GET / HTTP/1.1", host: "node1.localhost.comm"What is wrong?

Thank you.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments