Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
181529 1 server {
0ae8da 2         listen <tmpl_var name='ip_address'>:80;
8e2c2e 3 <tmpl_if name='ipv6_enabled'>
f2ded1 4         listen [<tmpl_var name='ipv6_address'>]:80;
8e2c2e 5 </tmpl_if>
0ae8da 6         
8e2c2e 7 <tmpl_if name='ssl_enabled'>
f7ec00 8         listen <tmpl_var name='ip_address'>:443 ssl{tmpl_if name='enable_spdy' op='==' value='y'} spdy{/tmpl_if};
53124e 9         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
8e2c2e 10 <tmpl_if name='ipv6_enabled'>
86bc65 11         listen [<tmpl_var name='ipv6_address'>]:443 ssl{tmpl_if name='enable_spdy' op='==' value='y'} spdy{/tmpl_if};
8e2c2e 12 </tmpl_if>
0ae8da 13         ssl_certificate <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.crt;
F 14         ssl_certificate_key <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.key;
8e2c2e 15 </tmpl_if>
0ae8da 16         
F 17         server_name <tmpl_var name='domain'> <tmpl_var name='alias'>;
181529 18
0ae8da 19         root   <tmpl_var name='web_document_root_www'>;
f92749 20         
8e2c2e 21 <tmpl_if name='seo_redirect_enabled'>
bfcdef 22         if ($http_host <tmpl_var name='seo_redirect_operator'> "<tmpl_var name='seo_redirect_origin_domain'>") {
a00888 23             rewrite ^ $scheme://<tmpl_var name='seo_redirect_target_domain'>$request_uri? permanent;
e64fbb 24         }
8e2c2e 25 </tmpl_if>
bfcdef 26 <tmpl_loop name="alias_seo_redirects">
T 27         if ($http_host <tmpl_var name='alias_seo_redirect_operator'> "<tmpl_var name='alias_seo_redirect_origin_domain'>") {
28             rewrite ^ $scheme://<tmpl_var name='alias_seo_redirect_target_domain'>$request_uri? permanent;
f92749 29         }
8e2c2e 30 </tmpl_loop>
43b345 31 <tmpl_loop name="local_redirects">
T 32         if ($http_host <tmpl_var name='local_redirect_operator'> "<tmpl_var name='local_redirect_origin_domain'>") {
33             rewrite ^<tmpl_var name='local_redirect_exclude'>(.*)$ <tmpl_var name='local_redirect_target'>$2 <tmpl_var name='local_redirect_type'>;
34         }
35 </tmpl_loop>
f0dfa9 36 <tmpl_if name='ssl_enabled'>
MC 37 <tmpl_if name='rewrite_to_https' op='==' value='y'>
38         if ($scheme != "https") {
39             rewrite ^ https://$http_host$request_uri? permanent;
40         }
41 </tmpl_if>
42 </tmpl_if>
bfcdef 43
T 44 <tmpl_loop name="own_redirects">
45 <tmpl_if name='use_rewrite'>
43b345 46         <tmpl_if name='exclude_own_hostname'>if ($http_host != "<tmpl_var name='exclude_own_hostname'>") { </tmpl_if>rewrite ^<tmpl_var name='rewrite_exclude'>(.*)$ <tmpl_var name='rewrite_target'>$2 <tmpl_var name='rewrite_type'>;<tmpl_if name='exclude_own_hostname'> }</tmpl_if>
bfcdef 47 </tmpl_if>
T 48 <tmpl_if name='use_proxy'>
49         location / {
50             proxy_pass <tmpl_var name='rewrite_target'>;
43b345 51             <tmpl_if name='rewrite_subdir'>rewrite ^/<tmpl_var name='rewrite_subdir'>(.*) /$1;</tmpl_if>
bfcdef 52 <tmpl_loop name="proxy_directives">
T 53         <tmpl_var name='proxy_directive'>
54 </tmpl_loop>
55         }
56 </tmpl_if>
57 </tmpl_loop>
58 <tmpl_if name='use_proxy' op='!=' value='y'>        
3c12a4 59         index index.html index.htm index.php index.cgi index.pl index.xhtml;
0ae8da 60         
8e2c2e 61 <tmpl_if name='ssi' op='==' value='y'>        
0ae8da 62         location ~ \.shtml$ {
F 63             ssi on;
64         }
8e2c2e 65 </tmpl_if>
0ae8da 66
8e2c2e 67 <tmpl_if name='errordocs'>        
0ae8da 68         error_page 400 /error/400.html;
F 69         error_page 401 /error/401.html;
70         error_page 403 /error/403.html;
71         error_page 404 /error/404.html;
72         error_page 405 /error/405.html;
73         error_page 500 /error/500.html;
445513 74         error_page 502 /error/502.html;
0ae8da 75         error_page 503 /error/503.html;
b67344 76         recursive_error_pages on;
T 77         location = /error/400.html {
bfcdef 78             <tmpl_var name='web_document_root_www_proxy'>
b67344 79             internal;
T 80         }
81         location = /error/401.html {
bfcdef 82             <tmpl_var name='web_document_root_www_proxy'>
b67344 83             internal;
T 84         }
85         location = /error/403.html {
bfcdef 86             <tmpl_var name='web_document_root_www_proxy'>
b67344 87             internal;
T 88         }
89         location = /error/404.html {
bfcdef 90             <tmpl_var name='web_document_root_www_proxy'>
b67344 91             internal;
T 92         }
93         location = /error/405.html {
bfcdef 94             <tmpl_var name='web_document_root_www_proxy'>
b67344 95             internal;
T 96         }
97         location = /error/500.html {
bfcdef 98             <tmpl_var name='web_document_root_www_proxy'>
b67344 99             internal;
T 100         }
101         location = /error/502.html {
bfcdef 102             <tmpl_var name='web_document_root_www_proxy'>
b67344 103             internal;
T 104         }
105         location = /error/503.html {
bfcdef 106             <tmpl_var name='web_document_root_www_proxy'>
b67344 107             internal;
T 108         }
8e2c2e 109 </tmpl_if>
0ae8da 110         
F 111         error_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log;
b6a10a 112         access_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/access.log combined;
0ae8da 113
F 114         ## Disable .htaccess and other hidden files
115         location ~ /\. {
116             deny all;
117             access_log off;
118             log_not_found off;
181529 119         }
0ae8da 120         
3c12a4 121         location = /favicon.ico {
0ae8da 122             log_not_found off;
F 123             access_log off;
124         }
125
126         location = /robots.txt {
127             allow all;
128             log_not_found off;
129             access_log off;
130         }
131         
992797 132         location /stats/ {
bfcdef 133             <tmpl_var name='web_document_root_www_proxy'>
0ae8da 134             index index.html index.php;
F 135             auth_basic "Members Only";
136             auth_basic_user_file <tmpl_var name='stats_auth_passwd_file'>;
137         }
138
b67344 139         location ^~ /awstats-icon {
8cf78b 140             alias /usr/share/awstats/icon;
T 141         }
142
0ae8da 143         location ~ \.php$ {
c8c13a 144             try_files <tmpl_var name='rnd_php_dummy_file'> @php;
e19c2e 145         }
F 146
147 <tmpl_if name='php' op='==' value='php-fpm'>
148         location @php {
f92749 149             try_files $uri =404;
ad9986 150             include /etc/nginx/fastcgi_params;
8e2c2e 151 <tmpl_if name='use_tcp'>
F 152             fastcgi_pass 127.0.0.1:<tmpl_var name='fpm_port'>;
153 </tmpl_if>
154 <tmpl_if name='use_socket'>
155             fastcgi_pass unix:<tmpl_var name='fpm_socket'>;
156 </tmpl_if>
0ae8da 157             fastcgi_index index.php;
F 158             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
43b345 159             #fastcgi_param PATH_INFO $fastcgi_script_name;
ad9986 160             fastcgi_intercept_errors on;
0ae8da 161         }
8e2c2e 162 </tmpl_else>
1c6da3 163     <tmpl_if name='php' op='==' value='hhvm'>
MC 164             location @php {
165                 try_files $uri =404;
166                 include /etc/nginx/fastcgi_params;
167                 fastcgi_pass unix:/var/run/hhvm/hhvm.<tmpl_var name='system_user'>.sock;
168                 fastcgi_index index.php;
169                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
170                 #fastcgi_param PATH_INFO $fastcgi_script_name;
171                 fastcgi_intercept_errors on;
172             }
173     </tmpl_else>
174
e19c2e 175         location @php {
0ae8da 176             deny all;
F 177         }
1c6da3 178     </tmpl_if>
8e2c2e 179 </tmpl_if>
0ae8da 180         
8e2c2e 181 <tmpl_if name='cgi' op='==' value='y'>
0ae8da 182         location /cgi-bin/ {
f92749 183             try_files $uri =404;
ad9986 184             include /etc/nginx/fastcgi_params;
0ae8da 185             root <tmpl_var name='document_root'>;
F 186             gzip off;
187             fastcgi_pass  unix:/var/run/fcgiwrap.socket;
188             fastcgi_index index.cgi;
189             fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
ad9986 190             fastcgi_intercept_errors on;
0ae8da 191         }
8e2c2e 192 </tmpl_if>
181529 193
615a0a 194 <tmpl_loop name="rewrite_rules">
T 195         <tmpl_var name='rewrite_rule'>
196 </tmpl_loop>
197
8e2c2e 198 <tmpl_loop name="nginx_directives">
3c12a4 199         <tmpl_var name='nginx_directive'>
8ab3cd 200 </tmpl_loop>
T 201
86bc65 202 <tmpl_if name='enable_pagespeed' op='==' value='y'>
MC 203         pagespeed on;
204         pagespeed FileCachePath /var/ngx_pagespeed_cache;
205         <tmpl_if name='ssl_enabled'>pagespeed FetchHttps enable,allow_self_signed;</tmpl_if>
206
207
208         # let's speed up PageSpeed by storing it in the super duper fast memcached
209         pagespeed MemcachedThreads 1;
210         pagespeed MemcachedServers "localhost:11211";
211
212         # Filter settings
213         pagespeed RewriteLevel CoreFilters;
214         pagespeed EnableFilters collapse_whitespace,remove_comments;
215
216         #  Ensure requests for pagespeed optimized resources go to the pagespeed
217         #  handler and no extraneous headers get set.
218         location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
219                 add_header "" "";
220                 access_log off;
221         }
222         location ~ "^/ngx_pagespeed_static/" {
223                 access_log off;
224         }
225         location ~ "^/ngx_pagespeed_beacon$" {
226                 access_log off;
227         }
228         location /ngx_pagespeed_statistics {
229                 allow 127.0.0.1;
230                 deny all;
231                 access_log off;
232         }
233         location /ngx_pagespeed_global_statistics {
234                 allow 127.0.0.1;
235                 deny all;
236                 access_log off;
237         }
238         location /ngx_pagespeed_message {
239                 allow 127.0.0.1;
240                 deny all;
241                 access_log off;
242         }
243         location /pagespeed_console {
244                 allow 127.0.0.1;
245                 deny all;
246                 access_log off;
247         }
248 </tmpl_if>
249
8ab3cd 250 <tmpl_loop name="basic_auth_locations">
9b16a3 251         location <tmpl_var name='htpasswd_location'> { ##merge##
8ab3cd 252                 auth_basic "Members Only";
T 253                 auth_basic_user_file <tmpl_var name='htpasswd_path'>.htpasswd;
e19c2e 254                 
F 255                 location ~ \.php$ {
53f048 256                     try_files <tmpl_var name='rnd_php_dummy_file'> @php;
e19c2e 257                 }
8ab3cd 258         }
T 259 </tmpl_loop>
bfcdef 260 </tmpl_if>    
T 261 }
262
263 <tmpl_loop name="redirects">
264 server {
265         listen <tmpl_var name='ip_address'>:80;
266 <tmpl_if name='ipv6_enabled'>
267         listen [<tmpl_var name='ipv6_address'>]:80;
268 </tmpl_if>
269         
270 <tmpl_if name='ssl_enabled'>
271         listen <tmpl_var name='ip_address'>:443 ssl;
272 <tmpl_if name='ipv6_enabled'>
273         listen [<tmpl_var name='ipv6_address'>]:443 ssl;
274 </tmpl_if>
275         ssl_certificate <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.crt;
276         ssl_certificate_key <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.key;
277 </tmpl_if>
278         
279         server_name <tmpl_var name='rewrite_domain'>;
280 <tmpl_if name='alias_seo_redirects2'>
281 <tmpl_loop name="alias_seo_redirects2">
282         if ($http_host <tmpl_var name='alias_seo_redirect_operator'> "<tmpl_var name='alias_seo_redirect_origin_domain'>") {
283             rewrite ^ $scheme://<tmpl_var name='alias_seo_redirect_target_domain'>$request_uri? permanent;
284         }
285 </tmpl_loop>
286 </tmpl_if>
287 <tmpl_if name='use_rewrite'>
288         rewrite ^ <tmpl_var name='rewrite_target'>$request_uri? <tmpl_var name='rewrite_type'>;
289 </tmpl_if>
290 <tmpl_if name='use_proxy'>
291         location / {
292             proxy_pass <tmpl_var name='rewrite_target'>;
43b345 293             <tmpl_if name='rewrite_subdir'>rewrite ^/<tmpl_var name='rewrite_subdir'>(.*) /$1;</tmpl_if>
bfcdef 294 <tmpl_loop name="proxy_directives">
T 295         <tmpl_var name='proxy_directive'>
296 </tmpl_loop>
297         }
298 </tmpl_if>
299 }
f7ec00 300 </tmpl_loop>