Skip to content

Commit 2d4c788

Browse files
authored
Merge pull request hestiacp#1196 from madito/main
Prestashop Nginx Templates
2 parents 7c160f0 + c395c01 commit 2d4c788

File tree

2 files changed

+279
-0
lines changed

2 files changed

+279
-0
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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+
location ~ /\.(?!well-known\/) {
34+
deny all;
35+
return 404;
36+
}
37+
38+
# Force pdf files to be downloaded
39+
location ~* \.pdf$ {
40+
add_header Content-Disposition Attachment;
41+
add_header X-Content-Type-Options nosniff;
42+
}
43+
44+
# Force files in upload directory to be downloaded
45+
location ~ ^/upload/ {
46+
add_header Content-Disposition Attachment;
47+
add_header X-Content-Type-Options nosniff;
48+
}
49+
50+
# [REQUIRED EDIT IF MULTILANG]
51+
# rewrite ^/fr$ /fr/ redirect;
52+
# rewrite ^/fr/(.*) /$1;
53+
54+
# Images
55+
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
56+
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
57+
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;
58+
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;
59+
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;
60+
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;
61+
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;
62+
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;
63+
rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
64+
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;
65+
66+
# AlphaImageLoader for IE and fancybox
67+
rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;
68+
69+
# Web service API
70+
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
71+
72+
# Installation sandbox
73+
rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
74+
75+
# Source code directories
76+
location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ {
77+
deny all;
78+
return 404;
79+
}
80+
81+
# vendor in modules directory
82+
location ~ ^/modules/.*/vendor/ {
83+
deny all;
84+
return 404;
85+
}
86+
87+
# Prevent exposing other sensitive files
88+
location ~ \.(yml|log|tpl|twig|sass)$ {
89+
deny all;
90+
return 404;
91+
}
92+
93+
# Prevent injection of php files
94+
location /upload {
95+
location ~ \.php$ {
96+
deny all;
97+
return 404;
98+
}
99+
}
100+
location /img {
101+
location ~ \.php$ {
102+
deny all;
103+
return 404;
104+
}
105+
}
106+
107+
location / {
108+
try_files $uri $uri/ /index.php?$args;
109+
110+
location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
111+
expires 30d;
112+
fastcgi_hide_header "Set-Cookie";
113+
}
114+
115+
location ~ [^/]\.php(/|$) {
116+
try_files $fastcgi_script_name /index.php$uri&$args =404;
117+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
118+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
119+
120+
fastcgi_pass %backend_lsnr%;
121+
fastcgi_index index.php;
122+
include /etc/nginx/fastcgi_params;
123+
}
124+
}
125+
126+
error_page 403 /error/404.html;
127+
error_page 404 /index.php?controller=404;
128+
error_page 500 502 503 504 /error/50x.html;
129+
130+
location /error/ {
131+
alias %home%/%user%/web/%domain%/document_errors/;
132+
}
133+
134+
location /vstats/ {
135+
alias %home%/%user%/web/%domain%/stats/;
136+
include %home%/%user%/web/%domain%/stats/auth.conf*;
137+
}
138+
139+
include /etc/nginx/conf.d/phpmyadmin.inc*;
140+
include /etc/nginx/conf.d/phppgadmin.inc*;
141+
include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
142+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
location ~ /\.(?!well-known\/) {
29+
deny all;
30+
return 404;
31+
}
32+
33+
# Force pdf files to be downloaded
34+
location ~* \.pdf$ {
35+
add_header Content-Disposition Attachment;
36+
add_header X-Content-Type-Options nosniff;
37+
}
38+
39+
# Force files in upload directory to be downloaded
40+
location ~ ^/upload/ {
41+
add_header Content-Disposition Attachment;
42+
add_header X-Content-Type-Options nosniff;
43+
}
44+
45+
# [REQUIRED EDIT IF MULTILANG]
46+
# rewrite ^/fr$ /fr/ redirect;
47+
# rewrite ^/fr/(.*) /$1;
48+
49+
# Images
50+
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
51+
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
52+
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;
53+
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;
54+
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;
55+
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;
56+
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;
57+
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;
58+
rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
59+
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;
60+
61+
# AlphaImageLoader for IE and fancybox
62+
rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;
63+
64+
# Web service API
65+
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
66+
67+
# Installation sandbox
68+
rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
69+
70+
# Source code directories
71+
location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ {
72+
deny all;
73+
return 404;
74+
}
75+
76+
# vendor in modules directory
77+
location ~ ^/modules/.*/vendor/ {
78+
deny all;
79+
return 404;
80+
}
81+
82+
# Prevent exposing other sensitive files
83+
location ~ \.(yml|log|tpl|twig|sass)$ {
84+
deny all;
85+
return 404;
86+
}
87+
88+
# Prevent injection of php files
89+
location /upload {
90+
location ~ \.php$ {
91+
deny all;
92+
return 404;
93+
}
94+
}
95+
location /img {
96+
location ~ \.php$ {
97+
deny all;
98+
return 404;
99+
}
100+
}
101+
102+
location / {
103+
try_files $uri $uri/ /index.php?$args;
104+
105+
location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
106+
expires 30d;
107+
fastcgi_hide_header "Set-Cookie";
108+
}
109+
110+
location ~ [^/]\.php(/|$) {
111+
try_files $fastcgi_script_name /index.php$uri&$args =404;
112+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
113+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
114+
115+
fastcgi_pass %backend_lsnr%;
116+
fastcgi_index index.php;
117+
include /etc/nginx/fastcgi_params;
118+
}
119+
}
120+
121+
error_page 403 /error/404.html;
122+
error_page 404 /index.php?controller=404;
123+
error_page 500 502 503 504 /error/50x.html;
124+
125+
location /error/ {
126+
alias %home%/%user%/web/%domain%/document_errors/;
127+
}
128+
129+
location /vstats/ {
130+
alias %home%/%user%/web/%domain%/stats/;
131+
include %home%/%user%/web/%domain%/stats/auth.conf*;
132+
}
133+
134+
include /etc/nginx/conf.d/phpmyadmin.inc*;
135+
include /etc/nginx/conf.d/phppgadmin.inc*;
136+
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
137+
}

0 commit comments

Comments
 (0)