1

I am setting up an older prestashop setup on a site and I am getting the following error on some products:

2017/08/09 17:11:03 [error] 19038#0: *414292 rewrite or internal redirection cycle while internally redirecting to "/index.php" while sending to client, client: <IP_CENSORED> , server: <DOMAIN_CENSORED>, request: "GET /5548-large_default/<URL CENSORED>.jpg HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "<HOST CENSORED>", referrer: "<REFERRER CENSORED>"

I tried using recommended configurations grabbed from the net as well as adding =404 to $uri $uri/ /index.php$is_args$args with no success. Here is my nginx configuration:

server {
    server_name      www.<SERVER NAME>;
    listen           80;
    root             /storage/<SERVER NAME>/;
    rewrite ^/(.*)$  http://<SERVER NAME>/$1 permanent;
}

server {
    server_name      www.<SERVER NAME>;
    listen           443;
    root             /storage/<SERVER NAME>/;
    rewrite ^/(.*)$  https://<SERVER NAME>/$1 permanent;
    include /etc/nginx/conf.d/ssl-<SERVER NAME>.conf;
}

server  {
    server_name     <SERVER NAME>;
    listen          80;
    root            /storage/<SERVER NAME>/;

    include /etc/nginx/conf.d/logging.conf;
    include /etc/nginx/conf.d/errors.conf;
    include /etc/nginx/conf.d/security.conf;

    #
    # PRESTASHOP rewrite
    # http://ix.sk/f7MhL
    # writable directories in docroot:
    # - log/ (-R)
    # - cache/ (-R, but should be probably revaluated)
    #

    index index.php;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location /cache/smarty/cache/ {
        return 404;
    }

    location / {
        rewrite ^/(.*)/img/cms/(.*).(jpe?g|png|gif)$ /img/cms/$2.$3 break;

        rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 break;
        rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg break;
        rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg break;
        rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg break;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg break;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg break;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg break;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg break;
        rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg break;
        rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg break;
        rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg break;
        rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 break;
        try_files $uri $uri/ /index.php$is_args$args;
        error_page 404 /index.php?controller=404;

        #location ~* \.(js|jsonp|css|png|jpg|jpeg|gif|ico)$ {
        #   expires 604800s;
        #   log_not_found off;
        #}
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/conf.d/fastcgi_pass.conf;
        fastcgi_read_timeout 600;
    }
}

server  {
    server_name     <SERVER NAME>;
    listen          443;
    root            /storage/<SERVER NAME>/;

    include /etc/nginx/conf.d/ssl-<SERVER NAME>.conf;
    include /etc/nginx/conf.d/logging.conf;
    include /etc/nginx/conf.d/errors.conf;
    include /etc/nginx/conf.d/security.conf;

    #
    # PRESTASHOP rewrite
    # http://ix.sk/f7MhL
    # writable directories in docroot:
    # - log/ (-R)
    # - cache/ (-R, but should be probably revaluated)
    #

    index index.php;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location /cache/smarty/cache/ {
        return 404;
    }

    rewrite ^/(.*)/img/cms/(.*).(jpe?g|png|gif)$ /img/cms/$2.$3 break;
    rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
    rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last;
    rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
    rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg last;
    rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
    rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 last;
    error_page 404 /index.php?controller=404;
    try_files $uri $uri/ /index.php$is_args$args;
    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/conf.d/fastcgi_pass.conf;
        fastcgi_read_timeout 600;
    }

    location ~* \.(js|jsonp|css|png|jpg|jpeg|gif|ico)$ {
        expires 604800s;
        log_not_found off;
    }
}

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.