We have NGinX as proxy server for PHP web application. PHP scripts are served by PHP-FPM process. Following is the configuration for the nginx:
location /app/ {
alias /var/www/html;
location ~* \.(js|css|png|jpg|jpeg|gif|ico|eot|svg|ttf|woff)$ {
alias /var/www/html;
expires 24h;
log_not_found on;
try_files $uri $uri;
}
rewrite /app.* /app/index.php?$args;
location ~ \.php$ {
try_files $uri =404;
# typical php-fpm configuration
}
}
# wordpress site hosted on root of the domain
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|eot|svg|ttf|woff)$ {
expires 24h;
log_not_found off;
auth_basic off;
}
PHP application itself is Yii based. Now issue is that when NGinx is serving a static image, it is truncating the actual path randomly (sometimes after 80 characters or sometimes after 4 dash in the url). e.g.
Lets say URL accessed is example.com/app/themes/app/images/some_folder/some_image_name.png
, it is showing 404 and in error.log I am seeing that NGinx is trying to locate following path /var/www/html/app/themes/app/images/some_folder/**some_image_name.pn/**
(g is removed from URL) while another image, whose file name is shorter than culprit one, at same location is being located successfully.
EDIT: We have noted a pattern, actually nginx is appending the $uri again after the original $uri i.e in above mentioned example it replace 'g' with '/' which is the starting character of the $uri and in another case it replace '.png' with '/var'. Hope it helps in debugging. :)