|
| 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 | +} |
0 commit comments