Last active
September 3, 2018 10:40
-
-
Save Lutacon/68fda4d5992661821dd6299245a9dafd to your computer and use it in GitHub Desktop.
Prestashop 1.7.3.3 Nginx conf + SSL (Letsencrypt) + HTTP/2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
charset utf-8; | |
#listen SERVER_IP:80; | |
server_name YOUR_SITE_DOMAIN www.YOUR_SITE_DOMAIN; | |
root ROOT_PATH_PRESTASHOP; | |
index index.php; | |
set $admin_dir /ADMIN_PATH; | |
access_log /var/log/nginx/domains/YOUR_SITE_DOMAIN.log combined; | |
#access_log /var/log/nginx/domains/YOUR_SITE_DOMAIN.bytes bytes; | |
error_log /var/log/nginx/domains/YOUR_SITE_DOMAIN.error.log error; | |
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; | |
} | |
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
## | |
# Gzip Settings | |
## | |
gzip on; | |
gzip_disable "msie6"; # Do people still use Internet Explorer 6? In that case, disable gzip and hope for the best! | |
gzip_vary on; # Also compress content with other MIME types than "text/html" | |
gzip_types application/json text/css application/javascript; # We only want to compress json, css and js. Compressing images and such isn't worth it | |
gzip_proxied any; | |
gzip_comp_level 6; # Set desired compression ratio, higher is better compression, but slower | |
gzip_buffers 16 8k; # Gzip buffer size | |
gzip_http_version 1.0; # Compress every type of HTTP request | |
# Global rewrite not depending on languages | |
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; | |
rewrite "^/c/([0-9]+)(\-[_a-zA-Z0-9-]*)/(.*)\.jpg$" /img/c/$1$2.jpg last; | |
rewrite "^/c/([_a-zA-Z-]+)/(.*)\.jpg$" /img/c/$1.jpg last; | |
rewrite "^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/(\P{M}\p{M}*)*\.jpg$" /img/p/$1-$2$3.jpg last; | |
rewrite "^/([0-9]+)\-([0-9]+)/(\P{M}\p{M}*)*\.jpg$" /img/p/$1-$2.jpg last; | |
rewrite "^/([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$1$2.jpg last; | |
rewrite "^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$1$2$3.jpg last; | |
rewrite "^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$1$2$3$4.jpg last; | |
rewrite "^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last; | |
rewrite "^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last; | |
rewrite "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last; | |
rewrite "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$6/$7/$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])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last; | |
rewrite "^/([0-9]+)\-(\P{M}\p{M}*)+\.html(.*)$" /index.php?controller=product&id_product=$1$3 last; | |
rewrite "^/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=category&id_category=$1$3 last; | |
rewrite "^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" /index.php?controller=product&id_product=$2$4 last; | |
rewrite "^/([0-9]+)__([a-zA-Z0-9-]*)(.*)$" /index.php?controller=supplier&id_supplier=$1$3 last; | |
rewrite "^/([0-9]+)_([a-zA-Z0-9-]*)(.*)$" /index.php?controller=manufacturer&id_manufacturer=$1$3 last; | |
rewrite "^/content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms=$1$3 last; | |
rewrite "^/content/category/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms_category=$1$3 last; | |
rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last; | |
rewrite "^/stock/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?controller=$1$2 last; | |
try_files $uri $uri/ /index.php?$args; | |
# Symfony controllers Specific for 1.7 | |
location ~ /(international|_profiler|module|product|combination|specific-price)/(.*)$ { | |
try_files $uri $uri/ /index.php?q=$uri&$args $admin_dir/index.php$is_args$args; | |
} | |
location /ADMIN_PATH/ { # Change this for your admin url | |
if (!-e $request_filename) { | |
rewrite ^/.*$ /ADMIN_PATH/index.php last; | |
} | |
} | |
location / { | |
if (!-e $request_filename) { | |
rewrite ^/.*$ /index.php last; | |
} | |
} | |
location ~ .php$ { | |
fastcgi_split_path_info ^(.+.php)(/.*)$; | |
try_files $uri =404; | |
fastcgi_keep_conn on; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_read_timeout 60m; | |
fastcgi_send_timeout 60m; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 256 16k; | |
fastcgi_max_temp_file_size 0; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_temp_file_write_size 256k; | |
} | |
listen SERVER_IP:443 ssl http2; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/YOUR_SITE_DOMAIN/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/YOUR_SITE_DOMAIN/privkey.pem; # managed by Certbot | |
ssl_session_cache shared:le_nginx_SSL:1m; | |
ssl_session_timeout 1440m; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem | |
} | |
server { | |
listen SERVER_IP:80; | |
server_name YOUR_SITE_DOMAIN; | |
return 301 https://$host$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace this variables:
YOUR_SITE_DOMAIN
SERVER_IP
ADMIN_PATH
ROOT_PATH_PRESTASHOP