0

I have a config that looks like:

server {
 listen 80;
 root /pubStuff;
 ...stuff...
 location /something {
  root /app/something
 }
}

The intention is, that while I can access stuff in the door of the server using example.com/ or with whatever directory/files location in /pubStuff, IF someone were to request example.com/something, or example.com/something/something.here.zip, they would get it!

When I try to go for example.com/something, I get a 404 not found error! In error log it says: 14#14: *15409 open() "/app/something/something" failed (2: no such file or directory)....

I dont understand why does it affix a second "something", when I asked for only example.com/something, which should show me the content of /app/something as configured above, right?

I read the documentation on http://nginx.org/en/docs/http/ngx_http_core_module.html#location but it is rather focused on the prefix matching stuff, not explaining whats wrong in my use case.

Based on stackoverflow suggestions, I tried the solution at Nginx -- static file serving confusion with root & alias

basically, it seems that only should only specify root /app/, and that it would go to /app/something/something.zip, but error log says it tries /pubStuff/something/something.zip, totally ignoring the root directive for /something.

Carmageddon
  • 2,627
  • 4
  • 36
  • 56
  • Did you actually try the `Alias` solution from the other answer you have linked? Mind the difference between `Root` and `Alias`. – Ext3h Jun 01 '20 at 20:37
  • Try: `root /app;` - see [this document](http://nginx.org/en/docs/http/ngx_http_core_module.html#root). – Richard Smith Jun 02 '20 at 08:41
  • @RichardSmith you are correct, along with removing the = in location, adding a trailing slash. Would you like to create an answer based on that? since your solution worked? – Carmageddon Jun 02 '20 at 16:27

0 Answers0