2

I have a .conf file existing in /etc/nginx/conf.d similar to the below

server {
    location /config/ {
        root /app/services/config;
        try_files $uri $uri/ $uri/config.json =404;
    }
}

config.json exists in /app/services/config however when my URI to the server is /config/config.json I am getting a 404 error.

1 Answer 1

2

The path in the URL request is appended to the filesystem path in the root directive, and the result is the path which is used to find the file.

In the case you illustrated, this results in:

/app/services/config/config/config.json
____________________ __________________
root                 URL

So, you must either place your files there, or change the URL path, or change the path in the root directive.

2
  • so changing root to /app/services should suffice in this case then?
    – PDStat
    Apr 2, 2019 at 14:18
  • @PDStat It looks like it to me. Apr 2, 2019 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.