0

I had a problem, with Nginx using the configuration from default nginx.conf.sample. When a client is accessing yet not existing cached product image, Nginx should rewrite the request to script /pub/get.php which would generate the image. However, Nginx was calling script /pub/errors/404.php, and instead of showing 404 error page, FastCGI was printing error "No input file specified.".

Related nginx logs:

2019/08/21 10:38:41 [error] 4044247#4044247: *1 open() "/home/user/public_html/pub/media/catalog/product/cache/9cdfca90d1ebe369f1fdfde371137e98/r/g/rg-bb-dun-snsn-gy.jpg" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: user.com, request: "GET /pub/media/catalog/product/cache/9cdfca90d1ebe369f1fdfde371137e98/r/g/rg-bb-dun-snsn-gy.jpg HTTP/1.1", host: "user.com"
2019/08/21 10:38:41 [error] 4044247#4044247: *1 FastCGI sent in stderr: "Unable to open primary script: /home/user/public_html/pub/errors/404.php (No such file or directory)" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: user.com, request: "GET /pub/media/catalog/product/cache/9cdfca90d1ebe369f1fdfde371137e98/r/g/rg-bb-dun-snsn-gy.jpg HTTP/1.1", upstream: "fastcgi://unix:/opt/cpanel/ea-php71/root/usr/var/run/php-fpm/6dd0db392f3aad14ca8dbafdc008594ac456e169.sock:", host: "user.com"

After some time trying to fix the issue, i changed

root $MAGE_ROOT/pub;
to
root $MAGE_ROOT;
, fully removed directive
location /pub/ {
    location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*.xml) {
        deny all;
    }
    alias $MAGE_ROOT/pub/;
    add_header X-Frame-Options "SAMEORIGIN";
}
and changed paths in pub locations so that they were written relative to root instead of pub alias:

location /pub/media/ {
    try_files $uri $uri/ /pub/get.php$is_args$args;

    location ~ ^/pub/media/theme_customization/.*\.xml {
        deny all;
    }

    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header Cache-Control "public";
        add_header X-Frame-Options "SAMEORIGIN";
        expires +1y;
        try_files $uri $uri/ /pub/get.php$is_args$args;
    }
    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
        add_header Cache-Control "no-store";
        add_header X-Frame-Options "SAMEORIGIN";
        expires    off;
        try_files $uri $uri/ /pub/get.php$is_args$args;
    }
    add_header X-Frame-Options "SAMEORIGIN";
}

And it started to work propely. But I don't understand why it don't work with alias.

  • server config is the last what you need to change... usually never. – MagenX Aug 22 at 16:34

Your Answer

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

Browse other questions tagged or ask your own question.