Помощь Подскажите с настройками nginx если преста 1.7.5 установлена в подпапку?

Тема в разделе "PrestaShop", создана пользователем Jarhead, 12 ноя 2019.

Метки:
Информация :
Приветствую гость, обрати внимание! Темы которые закреплены в разделах, в скором времени будут откреплены. Правила раздела PrestaShop

(Не актуальные темы) Каталоги:Модули PrestaShop 1.7Модули PrestaShop 1.5 - 1.6Шаблоны PrestaShop 1.7Шаблоны PrestaShop 1.5 - 1.6
(Не актуальные темы) Поиск / Запросы:Модули PrestaShop 1.7Модули PrestaShop 1.5 - 1.6Шаблоны PrestaShop 1.7Шаблоны PrestaShop 1.5 - 1.6
Полезная информация:Поддержка и помощь c PrestaShopУбираем ПрестаТраст, стучалки и прочую рекламуСовместные покупки модулей и шаблоновПеревод Prestashop и модулей
Модераторы: trace
  1. Jarhead

    Jarhead

    Регистр.:
    17 июн 2011
    Сообщения:
    407
    Симпатии:
    155
    Сайт установлен в папку /shop

    Сделал вот так в конфиге nginx:


    Код:
        location /shop {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /shop/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;
    
            error_page 404 /shop/index.php?controller=404;
        }
    Вроде все работает, но нет картинок у товаров везде, что не так?
     
  2. Jarhead

    Jarhead

    Регистр.:
    17 июн 2011
    Сообщения:
    407
    Симпатии:
    155
    Вот весь конфиг:


    Код:
    server {
        listen :443 ssl default_server;
        server_name site.ru www.site.ru;
        ssl_certificate "/etc/nginx/ssl.site.ru.crt";
        ssl_certificate_key "/etc/nginx/ssl.site.ru.key";
        set $root_path /var/www/hib/data/www/site.ru;
        disable_symlinks if_not_owner from=$root_path;
        root $root_path;
        index index.php;
        sendfile off;
    
        error_log /var/log/nginx/site.ru.error.log notice;
        access_log off;
    
        location /shop/ {
            client_max_body_size 1000m;
            client_body_buffer_size 128k;
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /shop/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;
    
            error_page 404 /shop/index.php?controller=404;
        }
    
        # 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)";
    
        # Symfony controllers
        location /shop/admin/ {
            if (!-e $request_filename) {
                rewrite ^/.*$ /shop/admin/index.php last;
            }
        }
    
        # Source code directories
        location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ {
            deny all;
        }
    
        # Cloudflare / Max CDN fix
        location ~* \.(eot|otf|ttf|woff(?:2)?)$ {
            add_header Access-Control-Allow-Origin *;
        }
    
        # Do not save logs for these
        location = /favicon.ico {
            auth_basic off;
            allow all;
            log_not_found off;
            access_log off;
        }
    
        location = /robots.txt {
            auth_basic off;
            allow all;
            log_not_found off;
            access_log off;
        }
    
        # 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;
            }
        }
    
        # pass the PHP scripts to FastCGI server listening on socket
        location ~ \.php$ {
            try_files $fastcgi_script_name /index.php$uri&$args =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/www/php-fpm/hib.sock;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_index index.php;
            fastcgi_connect_timeout 12000s;
            fastcgi_read_timeout 12000s;
            fastcgi_send_timeout 12000s;
            fastcgi_buffer_size 64k;
            fastcgi_buffers 16 64k;
            include fastcgi_params;
            fastcgi_keep_conn on;
            client_max_body_size 10M;
        }
    
        # deny access to . files, for security
        #
        location ~ /\. {
            log_not_found off;
            deny all;
        }
    
        location ^~ /.well-known {
            allow all;
            auth_basic off;
        }
    }

    Все работает за исключением картинок товаров, может знает кто в чем дело? установлана тема warehaouse, в админке фотки все есть
     
  3. Jarhead

    Jarhead

    Регистр.:
    17 июн 2011
    Сообщения:
    407
    Симпатии:
    155
    А все разобрался, если кому интересно нужно исправить на:


    Код:
            rewrite ^/shop/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$1$2$3.jpg last;
            rewrite ^/shop/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$2/$1$2$3$4.jpg last;
            rewrite ^/shop/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
            rewrite ^/shop/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
            rewrite ^/shop/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
            rewrite ^/shop/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
            rewrite ^/shop/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
            rewrite ^/shop/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /shop/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
            rewrite ^/shop/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /shop/img/c/$1$2$3.jpg last;
            rewrite ^/shop/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /shop/img/c/$1$2.jpg last;
     
    trace, fortuner, xxxATOMxxx и ещё 1-му нравится это.