Skip to content

Instantly share code, notes, and snippets.

@xros
Forked from alpiua/nginx prestashop
Created August 16, 2016 20:35
Show Gist options
  • Save xros/e235be179b281adfc66b380607877aa3 to your computer and use it in GitHub Desktop.
Save xros/e235be179b281adfc66b380607877aa3 to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name www.example.com;
rewrite ^ http://example.com$request_uri? permanent; #301 redirect
}
server {
listen 80;
server_name example.com;
root /home/www/example.com;
index index.php;
client_max_body_size 32m;
#client_header_buffer_size 16k;
#large_client_header_buffers 16 16k;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
include /etc/nginx/conf.d/prestashop.cfg;
# Admin zone no PATH_INFO // admin loop
location ~ /backend/.*\.php$ {
# include /opt/local/etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 32k;
fastcgi_buffers 4 32k;
}
location ~* \.(png|jpg|jpeg|gif|ico)$ {
access_log off;
expires max;
gzip off;
}
location ~* ^.+\.(css|js)$ {
access_log off;
expires 7d;
add_header Vary Accept-Encoding;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
#fastcgi_pass localhost:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param HTTP_MOD_REWRITE On;
include fastcgi_params;
#fastcgi_param QUERY_STRING $query_string;
#fastcgi_param REQUEST_METHOD $request_method;
#fastcgi_param CONTENT_TYPE $content_type;
#fastcgi_param CONTENT_LENGTH $content_length;
#fastcgi_intercept_errors on;
#fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
fastcgi_buffer_size 32k;
fastcgi_buffers 4 32k;
#fastcgi_busy_buffers_size 256k;
#fastcgi_temp_file_write_size 256k;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
}
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;
rewrite ^/page-not-found$ /index.php?controller=404 last;
try_files $uri $uri/ /index.php$is_args$args;
rewrite ^/page-not-found$ /index.php?controller=404 last;
#Advanced Search block options
location = /as4_seositemap.xml {
rewrite ^(.*)$ /modules/pm_advancedsearch4/sitemap/seositemap.xml break;
}
location /as4_seositemap {
rewrite ^/as4_seositemap-([0-9]+).xml$ /modules/pm_advancedsearch4/sitemap/seositemap-$1.xml break;
}
rewrite "^/([a-z]{2})?/?s/([0-9]+)/([a-zA-Z0-9/_-]*)" /index.php?fc=module&module=pm_advancedsearch4&controller=advancedsearch4&isolang=$1&id_seo=$2&seo_url=$3 break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment