I have a local setup that uses Docker and Nginx. It used to use port 80 but recently (non-root user related) it changed to port 8080. However, it still seems to use port 80 by default. If I map port 80:8080 then the containers are reached. However, if containers need to communicate between them, it will use port 80 and therefore, not reach eachother.
Here’s some more information:
docker-compose.yaml
build:
args:
nginx_config_file: nginx.conf
ports:
- "8000:8080" (also tried with 8080, 80:8000)
nginx.conf
worker_processes 1;
events { worker_connections 1024; }
http {
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;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
fastcgi_read_timeout 300;
sendfile on;
server {
listen 8080;
client_max_body_size 10M;
access_log off;
server_name "~^([w-]+).[w]+.[w]+.myserver.local$";
set $tenant $1;
location /access-identity/ {
rewrite ^/([^/]+)/(.*) /$2 break;
proxy_set_header Service $1;
proxy_set_header Tenant $tenant;
proxy_pass http://service-name:8080;
}
Snapshot of docker ps
How can I make sure that port 8080 is always used?