nginx ignoring config file when started via systemd

theheadsage nginx-forum at nginx.us
Tue Dec 8 05:36:40 UTC 2015


Hi Guys,

Got a somewhat interesting bug with nginx, which is where my config is being
ignored by nginx when it's started via systemd.

Here's the config:

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;

        location /nodejs/testnodebox {
            proxy_pass       http://127.0.0.1:7000;
            proxy_set_header Host      $host;
            proxy_set_header X-Real-IP $remote_addr;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

Now, this config works fine on another server, but on this one, when started
via systemd, visiting the URL results in the nginx 404 page.

2015/12/08 16:23:16 [error] 64787#0: *1 open()
"/usr/share/nginx/html/nodejs/testnodebox" failed (2: No such file or
directory), client: <IP>, server: _, request: "GET /nodejs/testnodebox
HTTP/1.1", host: "<snip>"

but if I kill nginx via systemctl stop nginx.service and start it manually
via sudo nginx (in the /etc/nginx/ directory) it reads the config and
proxies requests fine:

<IP> - - [08/Dec/2015:16:34:30 +1100] "GET /nodejs/testnodebox HTTP/1.1" 200
33 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/46.0.2490.86 Safari/537.36" "-"

I've tried enabling the debug log and that hasn't shown anything helpful. So
I'm somewhat stuck. Any ideas on what might be causing this? Anywhere I
should be looking?

Thanks for you help,

Daniel Sage

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,263342,263342#msg-263342



More information about the nginx mailing list