Prestashop: Error when working with NGinx and ban on the forum

Created on 19 Apr 2019  路  20Comments  路  Source: PrestaShop/PrestaShop

What is going on in your forum?
Registered, asked a question and after some time:
袙褘写械谢械薪懈械_002

Essence of the question:
Not work controllers in admin page:

  • /index.php/sell/catalog/products
  • /index.php/sell/orders/delivery-slips/
  • etc

Config file:

server {
    server_name * ;
    listen *;

    #
    index index.php index.html index.htm;

    # Gzip Settings, convert all types.
    gzip on;
    gzip_vary on;
    gzip_proxied any;

    gzip_types
        application/atom+xml
        application/javascript
        application/json
        application/ld+json
        application/manifest+json
        application/rss+xml
        application/vnd.geo+json
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-web-app-manifest+json
        application/xhtml+xml
        application/xml
        font/opentype
        image/bmp
        image/svg+xml
        image/x-icon
        text/cache-manifest
        text/css
        text/plain
        text/vcard
        text/vnd.rim.location.xloc
        text/vtt
        text/x-component
        text/x-cross-domain-policy;

    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    #
    set $root_path /var/www/*;
    root $root_path;
    # disable_symlinks if_not_owner from=$root_path;

    # Symfony controllers
    location /admin1250azhqw/ {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /admin1250azhqw/index.php last; 
        }
    }

    # Main
    location / {
        # Redirect pretty urls to index.php
        try_files $uri $uri/ /index.php?$args;

        # Images
        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;

        # AlphaImageLoader for IE and fancybox
        rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;

        # Web service API
        rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

        # Installation sandbox
        rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
    }

    # Redirect 404 errors to prestashop
    error_page 404 /index.php?controller=404;


    # Cloudflare / Max CDN fix
    location ~* \.(eot|otf|ttf|woff|woff2)$ {
        add_header Access-Control-Allow-Origin *;
    }

    # Do not save logs for these
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

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

    # File security
    # .htaccess .DS_Store .htpasswd etc
    location ~ /\. {
        deny all;
    }

    # Source code directories
    location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor)/ {
        deny all;
    }

    # Prevent exposing other sensitive files
    location ~ \.(yml|log|tpl|twig|sass)$ {
        deny all;
    }

    # Prevent injection of php files
    location /upload {
        location ~ \.php$ {
            deny all;
        }
    }

    #
    location /img {
        location ~ \.php$ {
            deny all;
        }
    }

    #
    location ~ \.php$ {
        # Verify that the file exists, redirect to index if not
        try_files $fastcgi_script_name /index.php$uri&$args;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:*;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    }
}

As a result:

  • ERR_TOO_MANY_REDIRECTS

    • 404 _(with different settings)_

Additionnal information
PrestaShop version: 1.7.5.1
PHP version: 7.3

1.7.5.1 BO Bug No change required

All 20 comments

Hi @ange007,

Thanks for your report.
First, PrestaShop is not compatible with PHP 7.3, in fact, PrestaShop 1.7.0 to 1.7.3 is compatible with PHP 7.1 and PrestaShop 1.7.4 & 1.7.5 are compatible with PHP 7.2.
For more details you can follow this link: http://build.prestashop.com/news/prestashop-1-7-is-moving-to-symfony-3-4-and-php-5-6/
Thanks to downgrade your PHP version, check & feedback.

Hello.
No changes.
The bulk of the function with links to the controller=* - work on 7.3 and 7.2, without - do not work

@ange007, I did not manage to reproduce your issue with PS1.7.5.1 & nginx server nginx/1.14.0
I attached a video record
https://drive.google.com/file/d/1zZ9CW4lCPMGfWLoBkUxQ4XxZ7nqsgP3i/view
It is an issue related to your configuration
here's my nginx configuration

server {
    listen   80; ## listen for ipv4; this line is default and implied
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www/html;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name _;

    # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
    sendfile off;

    # Add stdout logging
    # Add stdout logging
        error_log /var/log/nginx/error.log info;
        access_log /var/log/nginx/access.log;

        # Add option for x-forward-for (real ip when behind elb)
        #real_ip_header X-Forwarded-For;
        #set_real_ip_from 172.16.0.0/12;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to index.html
        try_files $uri $uri/ /1750/index.php?$args;
        # Images
                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;
        # AlphaImageLoader for IE and fancybox
        rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;

        # Web service API
        rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

        # Installation sandbox
        rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
    }
    # Gzip Settings, convert all types.
        gzip on;
        gzip_vary on;
        gzip_proxied any;

        # Can be enhance to 5, but it can slow you server
        # gzip_comp_level    5;
        # gzip_min_length    256;

        gzip_types
            application/atom+xml
            application/javascript
            application/json
            application/ld+json
            application/manifest+json
            application/rss+xml
            application/vnd.geo+json
            application/vnd.ms-fontobject
            application/x-font-ttf
            application/x-web-app-manifest+json
            application/xhtml+xml
            application/xml
            font/opentype
            image/bmp
            image/svg+xml
            image/x-icon
            text/cache-manifest
            text/css
            text/plain
            text/vcard
            text/vnd.rim.location.xloc
            text/vtt
            text/x-component
            text/x-cross-domain-policy;

        gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    # Symfony controllers
        location /1750/admin-dev/ {                                  # [REQUIRED EDIT] the name of your admin directory
            if (!-e $request_filename) {
                rewrite ^/.*$ /1750/admin-dev/index.php last;   # [REQUIRED EDIT] the name of your admin directory
            }
        }

        # Cloudflare / Max CDN fix
        location ~* \.(eot|otf|ttf|woff|woff2)$ {
            add_header Access-Control-Allow-Origin *;
        }

        # Do not save logs for these
        location = /1750/favicon.ico {
            log_not_found off;
            access_log off;
        }
        location = /1750/robots.txt {
            auth_basic off;
            allow all;
            log_not_found off;
            access_log off;
        }


    error_page 404 /1750/index.php?controller=404;

        location ^~ /sad.svg {
            alias /var/www/errors/sad.svg;
            access_log off;
        }
        location ^~ /twitter.svg {
            alias /var/www/errors/twitter.svg;
            access_log off;
        }
        location ^~ /gitlab.svg {
            alias /var/www/errors/gitlab.svg;
            access_log off;
        }

    # pass the PHP scripts to FastCGI server listening on socket
    #
    location ~ \.php$ {
                try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
    }

        location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {
                expires           5d;
        }

    # deny access to . files, for security
    #
    location ~ /\. {
            log_not_found off; 
            deny all;
    }

    location ^~ /.well-known {
                allow all;
                auth_basic off;
        }

}

I followed this link https://github.com/PrestaShop/PrestaShop/blob/develop/docs/docker/nginx_fpm/prestashop-nginx/prestashop-nginx.conf
Thanks to check & feedback.

@khouloudbelguith, I saw your messages about this, and as you can see my config is similar to yours _(it is compiled from the docker config and yours)_.
But it doesn't work anyway.
Therefore, I asked a clarifying question on forum to one of the users who encountered this. But I was banned.

@ange007, in your file I found this

set $root_path /var/www/*;
    root $root_path;

your project PrestaShop folder is located in the /var/www/path?
Thanks!

I just hidden the domain data.
Real path: set $root_path /var/www/site/data/www/site;
I think that in the case of an incorrectly specified path, what worked now would not work _(although I could be wrong)_.

@ange007, you need to define all rules in your nginx configuration, the .htacces file is generated by prestashop but it's because Apache allows to use it. Unlike Nginx.
It could be related, in your server the extension is enbled tokenizer?
image
If you run php -m on the command line, tokenizer is in the list?
Thanks to check & feedback.

@ange007, about your problem on the forum, you can send an email to this address [email protected] and describe your issue.
Thanks!

@ange007, you need to define all rules in your nginx configuration, the .htacces file is generated by prestashop but it's because Apache allows to use it. Unlike Nginx.
It could be related, in your server the extension is enbled tokenizer?
image
If you run php -m on the command line, tokenizer is in the list?
Thanks to check & feedback.

Yes, Tokenizer exists

I鈥榲e also found myself banned on the forum for whatever reason :)

Hi @ange007,

Could you please provide us with more info? We need more details to understand how we can reproduce your issue:

  • server setup and configuration
  • debug mode report
  • PHP error logs
  • apache error log
  • javascript console log

Don't you know how to get this information? Please read the following article:
http://build.prestashop.com/howtos/misc/how-to-create-bug-report/

@rdy4ever you should send an email to this address [email protected].
Thanks!

@rdy4ever you should send an email to this address [email protected].
Thanks!

I did. No answer.

@rdy4ever, today is a holiday, they will answer you soon.
Thanks!

@rdy4ever, today is a holiday, they will answer you soon.
Thanks!

Yeap, except that I sent my message over a week ago :)

  • server setup and configuration
  • Debian 9 x64, PHP-FPM ( php70 ), 10.1.37-MariaDB
  • CONFIG
  • debug mode report

dev.log

  • PHP error logs

Empty

  • apache error log
  • Only: "/favicon.ico" failed (2: No such file or directory)
  • ScreenShot
  • javascript console log

Empty

@ange007, in your config file could you please replace this line
rewrite ^/(.*)$ /admin1250azhqw/index.php last;
with this line
rewrite ^/.*$ /admin1250azhqw/index.php last;

Like in our documentation
https://github.com/PrestaShop/PrestaShop/blob/develop/docs/docker/nginx_fpm/prestashop-nginx/prestashop-nginx.conf#L58
Thanks to check & feedback.

@ange007, in your config file could you please replace this line
rewrite ^/(.*)$ /admin1250azhqw/index.php last;
with this line
rewrite ^/.*$ /admin1250azhqw/index.php last;

It makes no difference.
I tried many different options.

@ange007, did you reload your server after this modification?
Could you please try to clear cache manually by deleting all the folder into var/cache (prod & dev).
Thanks!

@rdy4ever you should send an email to this address [email protected].
Thanks!

I did. No answer.

Hi @rdy4ever and @ange007 there was several wrong bans recently on the forum. One of you has been fixed I think 馃槃please reach again [email protected] if this is not the case

Hi @ange007,

Since we had no news from you for more than 30 days, I'll close this ticket. Feel free to open another one if you can give specific details.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings