1

After reinstalling ubuntu nginx config doesn't want to work. try_files with correct root path doesn't find files. Here is my config

server {
       listen 80;
       listen 443 ssl;
       server_name maiden.local evermaiden.local;

       root /home/aeonax/lid/evermaiden/resources/public;
       access_log /home/aeonax/lid/evermaiden/resources/public/logs/nginx.log mrgl;

       location / {
                   try_files $uri $uri/ @clj;
                   proxy_set_header Host $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       }

       location @clj {
                   proxy_pass http://0.0.0.0:4444;
                   proxy_set_header Host $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       }
}

Log format:

log_format mrgl '\n uri: $uri'
                '\n document root: $document_root'
                '\n realpath root: $realpath_root'
                '\n doc + uri: $document_root$uri';

Log output:

uri: /test.jpg
document root: /home/aeonax/lid/evermaiden/resources/public
realpath root: -
doc + uri: /home/aeonax/lid/evermaiden/resources/public/test.jpg

uri: /assets/common.css
document root: /home/aeonax/lid/evermaiden/resources/public
realpath root: -
doc + uri: /home/aeonax/lid/evermaiden/resources/public/assets/common.css

uri: /assets/evermaiden.js
document root: /home/aeonax/lid/evermaiden/resources/public
realpath root: -
doc + uri: /home/aeonax/lid/evermaiden/resources/public/assets/evermaiden.js

What is going wrong here? Nginx have access to the folder(log file work well), all that files exist and store near logs/nginx.log... first request should return image, but it proceed to the server-_- another requests should return assets, but...
I tried to reinstall it with purge nginx nginx-common nginx-full, I tried other versions (1.12->1.13) but it still doesn't work.

Ben Hare
  • 4,365
  • 5
  • 27
  • 44
Khajiit
  • 21
  • 4

1 Answers1

1

Thanks to @TarunLalwani i remembered about default logs in /var/logs and when i visit it.... it was facepalm -_-

 2017/09/20 23:13:44 [crit] 30316#30316: *1 realpath() "/home/aeonax/lid/evermaiden/resources/public" 
 failed (13: Permission denied) while logging request, client: 127.0.0.1, server: maiden.local, 
 request: "GET /test.jpg HTTP/1.1", upstream: "http://0.0.0.0:4444/test.jpg", host: "maiden.local"

After this, problem disappeared and i found solution here.


make sure that username group can enter all directories along the path:

chmod g+x /username && chmod g+x /username/test && chmod g+x /username/test/static
Khajiit
  • 21
  • 4