Score:0

Nginx behaves differently with the same site configuration in different docker images

cn flag
nginx site config
    server {
    listen 80;
    server_name _;
    server_tokens off;
    gzip_static on;

    location ~* \.(html)$ {
        add_header 'X-XSS-Protection' '1';
    }

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }
}

it works perfect with docker image node:14.19.3 (nginx/1.14.2), but with node:14-alpine (nginx/1.22.1) it behaves differently:

  • trying accessing index.html (or /) redirects to default /var/lib/nginx/index.html (renders "Welcome to Nginx!"), though /usr/share/nginx/html/index.html exists and with permissions everything is OK
  • if copy /usr/share/nginx/html/index.html to /usr/share/nginx/html/index.txt - it is opened (http://<<mydomain>/index.txt)
  • if copy /usr/share/nginx/html/index.html to /usr/share/nginx/html/i.html - 404 - not found (http://<<mydomain>/i.html, well, it just can't find it in /var/lib/nginx/i.html)
  • if remove the upper location block from the site config everything works perfect (there is just no that extra response header)
Lex Li avatar
vn flag
You will have to compare the entire nginx config files (not a single one) from machine to machine to learn what are the differences.
us flag
Run `nginx -T` on both setups and compare the differences.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.