Skip to content

Commit 2ac96e4

Browse files
author
Arturo Blanco
authored
Add prestashop tpl
Add prestashop template for nginx. Ref https://devdocs.prestashop.com/1.7/basics/installation/nginx/
1 parent 789a2b0 commit 2ac96e4

File tree

2 files changed

+371
-0
lines changed

2 files changed

+371
-0
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
#=======================================================================#
2+
# Default Web Domain Template #
3+
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
4+
#=======================================================================#
5+
6+
server {
7+
listen %ip%:%web_ssl_port% ssl http2;
8+
server_name %domain_idn% %alias_idn%;
9+
root %docroot%;
10+
index index.php index.html index.htm;
11+
access_log /var/log/nginx/domains/%domain%.log combined;
12+
access_log /var/log/nginx/domains/%domain%.bytes bytes;
13+
error_log /var/log/nginx/domains/%domain%.error.log error;
14+
15+
ssl_certificate %ssl_pem%;
16+
ssl_certificate_key %ssl_key%;
17+
ssl_stapling on;
18+
ssl_stapling_verify on;
19+
20+
include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
21+
22+
location = /favicon.ico {
23+
log_not_found off;
24+
access_log off;
25+
}
26+
27+
location = /robots.txt {
28+
allow all;
29+
log_not_found off;
30+
access_log off;
31+
}
32+
33+
# Gzip Settings, convert all types.
34+
gzip on;
35+
gzip_vary on;
36+
gzip_proxied any;
37+
38+
# Can be enhance to 5, but it can slow you server
39+
# gzip_comp_level 5;
40+
# gzip_min_length 256;
41+
42+
gzip_types
43+
application/atom+xml
44+
application/javascript
45+
application/json
46+
application/ld+json
47+
application/manifest+json
48+
application/rss+xml
49+
application/vnd.geo+json
50+
application/vnd.ms-fontobject
51+
application/x-font-ttf
52+
application/x-web-app-manifest+json
53+
application/xhtml+xml
54+
application/xml
55+
font/opentype
56+
image/bmp
57+
image/svg+xml
58+
image/x-icon
59+
text/cache-manifest
60+
text/css
61+
text/plain
62+
text/vcard
63+
text/vnd.rim.location.xloc
64+
text/vtt
65+
text/x-component
66+
text/x-cross-domain-policy;
67+
68+
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
69+
70+
# Cloudflare / Max CDN fix
71+
location ~* \.(eot|otf|ttf|woff(?:2)?)$ {
72+
add_header Access-Control-Allow-Origin *;
73+
}
74+
75+
# Force pdf files to be downloaded
76+
location ~* \.pdf$ {
77+
add_header Content-Disposition Attachment;
78+
add_header X-Content-Type-Options nosniff;
79+
}
80+
81+
# Force files inupload directory to be downloaded
82+
location ~ ^/upload/ {
83+
add_header Content-Disposition Attachment;
84+
add_header X-Content-Type-Options nosniff;
85+
}
86+
87+
# [REQUIRED EDIT IF MULTILANG]
88+
# rewrite ^/fr$ /fr/ redirect;
89+
# rewrite ^/fr/(.*) /$1;
90+
91+
# Images
92+
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
93+
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
94+
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;
95+
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;
96+
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;
97+
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;
98+
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;
99+
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;
100+
rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
101+
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;
102+
103+
# AlphaImageLoader for IE and fancybox
104+
rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;
105+
106+
# Web service API
107+
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
108+
109+
# Installation sandbox
110+
rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
111+
112+
# Source code directories
113+
location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ {
114+
deny all;
115+
}
116+
# vendor in modules directory
117+
location ~ ^/modules/.*/vendor/ {
118+
deny all;
119+
}
120+
# Prevent exposing other sensitive files
121+
location ~ \.(yml|log|tpl|twig|sass)$ {
122+
deny all;
123+
}
124+
125+
# Prevent injection of php files
126+
location /upload {
127+
location ~ \.php$ {
128+
deny all;
129+
}
130+
}
131+
location /img {
132+
location ~ \.php$ {
133+
deny all;
134+
}
135+
}
136+
137+
location / {
138+
try_files $uri $uri/ /index.php?$args;
139+
140+
if (!-e $request_filename)
141+
{
142+
rewrite ^(.+)$ /index.php?q=$1 last;
143+
}
144+
145+
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
146+
expires max;
147+
fastcgi_hide_header "Set-Cookie";
148+
}
149+
150+
location ~ [^/]\.php(/|$) {
151+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
152+
153+
try_files $fastcgi_script_name /index.php$uri&$args =404;
154+
155+
# Environment variables for PHP
156+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
157+
158+
fastcgi_pass %backend_lsnr%;
159+
fastcgi_index index.php;
160+
include /etc/nginx/fastcgi_params;
161+
}
162+
}
163+
164+
error_page 403 /error/404.html;
165+
error_page 404 /index.php?controller=404;
166+
error_page 500 502 503 504 /error/50x.html;
167+
168+
169+
location /error/ {
170+
alias %home%/%user%/web/%domain%/document_errors/;
171+
}
172+
173+
location ~* "/\.(htaccess|htpasswd)$" {
174+
deny all;
175+
return 404;
176+
}
177+
178+
location /vstats/ {
179+
alias %home%/%user%/web/%domain%/stats/;
180+
include %home%/%user%/web/%domain%/stats/auth.conf*;
181+
}
182+
183+
include /etc/nginx/conf.d/phpmyadmin.inc*;
184+
include /etc/nginx/conf.d/phppgadmin.inc*;
185+
include /etc/nginx/conf.d/webmail.inc*;
186+
187+
include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
188+
}
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
#=======================================================================#
2+
# Default Web Domain Template #
3+
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
4+
#=======================================================================#
5+
6+
server {
7+
listen %ip%:%web_port%;
8+
server_name %domain_idn% %alias_idn%;
9+
root %docroot%;
10+
index index.php index.html index.htm;
11+
access_log /var/log/nginx/domains/%domain%.log combined;
12+
access_log /var/log/nginx/domains/%domain%.bytes bytes;
13+
error_log /var/log/nginx/domains/%domain%.error.log error;
14+
15+
include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
16+
17+
location = /favicon.ico {
18+
log_not_found off;
19+
access_log off;
20+
}
21+
22+
location = /robots.txt {
23+
allow all;
24+
log_not_found off;
25+
access_log off;
26+
}
27+
28+
# Gzip Settings, convert all types.
29+
gzip on;
30+
gzip_vary on;
31+
gzip_proxied any;
32+
33+
# Can be enhance to 5, but it can slow you server
34+
# gzip_comp_level 5;
35+
# gzip_min_length 256;
36+
37+
gzip_types
38+
application/atom+xml
39+
application/javascript
40+
application/json
41+
application/ld+json
42+
application/manifest+json
43+
application/rss+xml
44+
application/vnd.geo+json
45+
application/vnd.ms-fontobject
46+
application/x-font-ttf
47+
application/x-web-app-manifest+json
48+
application/xhtml+xml
49+
application/xml
50+
font/opentype
51+
image/bmp
52+
image/svg+xml
53+
image/x-icon
54+
text/cache-manifest
55+
text/css
56+
text/plain
57+
text/vcard
58+
text/vnd.rim.location.xloc
59+
text/vtt
60+
text/x-component
61+
text/x-cross-domain-policy;
62+
63+
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
64+
65+
# Cloudflare / Max CDN fix
66+
location ~* \.(eot|otf|ttf|woff(?:2)?)$ {
67+
add_header Access-Control-Allow-Origin *;
68+
}
69+
70+
# Force pdf files to be downloaded
71+
location ~* \.pdf$ {
72+
add_header Content-Disposition Attachment;
73+
add_header X-Content-Type-Options nosniff;
74+
}
75+
76+
# Force files inupload directory to be downloaded
77+
location ~ ^/upload/ {
78+
add_header Content-Disposition Attachment;
79+
add_header X-Content-Type-Options nosniff;
80+
}
81+
82+
# [REQUIRED EDIT IF MULTILANG]
83+
# rewrite ^/fr$ /fr/ redirect;
84+
# rewrite ^/fr/(.*) /$1;
85+
86+
# Images
87+
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
88+
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
89+
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;
90+
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;
91+
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;
92+
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;
93+
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;
94+
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;
95+
rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
96+
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;
97+
98+
# AlphaImageLoader for IE and fancybox
99+
rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;
100+
101+
# Web service API
102+
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
103+
104+
# Installation sandbox
105+
rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
106+
107+
# Source code directories
108+
location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ {
109+
deny all;
110+
}
111+
# vendor in modules directory
112+
location ~ ^/modules/.*/vendor/ {
113+
deny all;
114+
}
115+
# Prevent exposing other sensitive files
116+
location ~ \.(yml|log|tpl|twig|sass)$ {
117+
deny all;
118+
}
119+
120+
# Prevent injection of php files
121+
location /upload {
122+
location ~ \.php$ {
123+
deny all;
124+
}
125+
}
126+
location /img {
127+
location ~ \.php$ {
128+
deny all;
129+
}
130+
}
131+
132+
location / {
133+
try_files $uri $uri/ /index.php?$args;
134+
135+
if (!-e $request_filename)
136+
{
137+
rewrite ^(.+)$ /index.php?q=$1 last;
138+
}
139+
140+
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
141+
expires max;
142+
fastcgi_hide_header "Set-Cookie";
143+
}
144+
145+
location ~ [^/]\.php(/|$) {
146+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
147+
148+
try_files $fastcgi_script_name /index.php$uri&$args =404;
149+
150+
# Environment variables for PHP
151+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
152+
153+
fastcgi_pass %backend_lsnr%;
154+
fastcgi_index index.php;
155+
include /etc/nginx/fastcgi_params;
156+
}
157+
}
158+
159+
error_page 403 /error/404.html;
160+
error_page 404 /index.php?controller=404;
161+
error_page 500 502 503 504 /error/50x.html;
162+
163+
164+
location /error/ {
165+
alias %home%/%user%/web/%domain%/document_errors/;
166+
}
167+
168+
location ~* "/\.(htaccess|htpasswd)$" {
169+
deny all;
170+
return 404;
171+
}
172+
173+
location /vstats/ {
174+
alias %home%/%user%/web/%domain%/stats/;
175+
include %home%/%user%/web/%domain%/stats/auth.conf*;
176+
}
177+
178+
include /etc/nginx/conf.d/phpmyadmin.inc*;
179+
include /etc/nginx/conf.d/phppgadmin.inc*;
180+
include /etc/nginx/conf.d/webmail.inc*;
181+
182+
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
183+
}

0 commit comments

Comments
 (0)