I have used docker image nginx:1.18.0-alpine
previously
and below is the conf. It works as expected
app.localhost
--> points to the block wit server_name app.*
localhost
--> points to the other block
irrepective of their order
upstream webapp {
server webapp:8000;
}
server {
listen 80;
server_name app.*;
#access_log /var/log/nginx/app.access.log;
#error_log /var/log/nginx/app.error.log;
location / {
proxy_pass http://webapp;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
# https://serverfault.com/a/993559
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
proxy_send_timeout 1800;
send_timeout 1800;
}
}
server {
listen 80;
#access_log /var/log/nginx/normal.access.log;
#error_log /var/log/nginx/normal.error.log;
#server_name unicornpost.com;
root /usr/share/nginx/html;
index index.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
}
where as nginx/1.23.4
with the same above configuration
localhost
or app.localhost
always points to the first server block irrepective of server_name app.*
or no server_name
`