pvanthony Posted July 23, 2018 Share Posted July 23, 2018 Really need help to get prestashop 1.7.4.1 to work with nginx. Searched the web and tried the included nginx configs but just cannot get it to work. I hope someone has a working config for nginx. Link to comment Share on other sites More sharing options...
ksaan Posted July 26, 2018 Share Posted July 26, 2018 Have a look at this: https://github.com/PrestaShop/PrestaShop/pull/9047/files This is someone who configured a docker container for Prestashop using nginx 1 Link to comment Share on other sites More sharing options...
pvanthony Posted August 1, 2018 Author Share Posted August 1, 2018 Thank you very much for sharing this link. It works great now with 1.7.4.2. Once again thank you for the link to the nginx configuration. Really helpful. 1 Link to comment Share on other sites More sharing options...
ksaan Posted August 2, 2018 Share Posted August 2, 2018 You're welcome and I see now on the Pull Request it has been merged so it will be shipped with the next version of prestashop Link to comment Share on other sites More sharing options...
pvanthony Posted August 8, 2018 Author Share Posted August 8, 2018 That is great! Link to comment Share on other sites More sharing options...
Guest Posted August 28, 2018 Share Posted August 28, 2018 Thank you Link to comment Share on other sites More sharing options...
jean7373 Posted August 6, 2019 Share Posted August 6, 2019 # WebPGenerator Module - Do not edit RewriteRule . - [E=REWRITEBASE:/] # Apache 2.2 <IfModule !mod_authz_core.c> <Files ~ "(?i)^.*\.(webp)$"> Allow from all </Files> </IfModule> # Apache 2.4 <IfModule mod_authz_core.c> <Files ~ "(?i)^.*\.(webp)$"> Require all granted allow from all </Files> </IfModule> <IfModule mod_setenvif.c> SetEnvIf Request_URI "\.(jpe?g|png)$" REQUEST_image </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1.webp -f RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp] </IfModule> <IfModule mod_headers.c> Header append Vary Accept env=REQUEST_image </IfModule> <IfModule mod_mime.c> AddType image/webp .webp </IfModule> #Domain: www.mondopresepiprova.it RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.webp [L] RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.webp [L] RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.webp [L] RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.webp [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.webp [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.webp [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.webp [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/c/$1$2$3.webp [L] RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$ RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/c/$1$2.webp [L] # WebPGenerator Module - Do not edit but on nginx i tried everything but no conversione.. i tried this: location ~* ^/.+\.(png|jpg)$ { add_header Vary Accept; try_files $uri$webp_suffix $uri =404; } rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$1$2$3.webp last; rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$1$2$3$4.webp last; rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$1$2$3$4$5.webp last; rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.webp last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.webp last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.webp last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.webp last; rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.webp$ /img/c/$1$2$3.webp last; rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.webp$ /img/c/$1$2.webp last; what i have to do now? Link to comment Share on other sites More sharing options...
pvanthony Posted August 6, 2019 Author Share Posted August 6, 2019 This is what I use. # to control the amount that can be uploaded. client_max_body_size 50M; # Redirect 404 errors to prestashop error_page 404 /index.php?controller=404; # Symfony controllers location /yourAdminFolder/ { # [REQUIRED EDIT] the name of your admin directory if (!-e $request_filename) { rewrite ^/.*$ /yourAdminFolder/index.php last; # [REQUIRED EDIT] the name of your admin directory } } 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; } # 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; } } Link to comment Share on other sites More sharing options...
Puppo Posted April 22, 2020 Share Posted April 22, 2020 sorry for warming up this thread but can someone please explain me where i have to put the code above? I have read the informations on github but for me it isn't clear what i have to do. Would apreciate any advise. Maybe from @ksaan ? We use PS 1.7.6.4 Thx! Link to comment Share on other sites More sharing options...
siomosp Posted April 23, 2020 Share Posted April 23, 2020 (edited) Hi! • Usually the paths is /etc/nginx/sites-available/ • It should have a .conf file with your domain name yourdomainname.conf in my case it is "stickit.gr.conf" • Replace the contents of the yourdomainname.conf , with the above code ( keep a copy of the original file) edit the " [REQUIRED EDIT] the name of your admin directory" parts • Save the file , restart nginx ( you can use "nginx -t " to test if the conf file is ok ) Edited April 23, 2020 by siomosp (see edit history) 1 Link to comment Share on other sites More sharing options...
Puppo Posted April 23, 2020 Share Posted April 23, 2020 Thank you @siomosp Ok, I understand. Our Provider (Hosteurope) offers NGINX in our product, but settings can done only with .htaccess So i think, that your explanation is only for root servers and not vor virtual servers. 😞 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now