1 | # Aegir web server main configuration file |
---|
2 | |
---|
3 | ####################################################### |
---|
4 | ### nginx.conf main |
---|
5 | ####################################################### |
---|
6 | |
---|
7 | ## FastCGI params |
---|
8 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
---|
9 | fastcgi_param QUERY_STRING $query_string; |
---|
10 | fastcgi_param REQUEST_METHOD $request_method; |
---|
11 | fastcgi_param CONTENT_TYPE $content_type; |
---|
12 | fastcgi_param CONTENT_LENGTH $content_length; |
---|
13 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; |
---|
14 | fastcgi_param REQUEST_URI $request_uri; |
---|
15 | fastcgi_param DOCUMENT_URI $document_uri; |
---|
16 | fastcgi_param DOCUMENT_ROOT $document_root; |
---|
17 | fastcgi_param SERVER_PROTOCOL $server_protocol; |
---|
18 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; |
---|
19 | fastcgi_param SERVER_SOFTWARE ApacheSolaris/$nginx_version; |
---|
20 | fastcgi_param REMOTE_ADDR $remote_addr; |
---|
21 | fastcgi_param REMOTE_PORT $remote_port; |
---|
22 | fastcgi_param SERVER_ADDR $server_addr; |
---|
23 | fastcgi_param SERVER_PORT $server_port; |
---|
24 | fastcgi_param SERVER_NAME $server_name; |
---|
25 | fastcgi_param USER_DEVICE $device; |
---|
26 | fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code; |
---|
27 | fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3; |
---|
28 | fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name; |
---|
29 | fastcgi_param REDIRECT_STATUS 200; |
---|
30 | fastcgi_index index.php; |
---|
31 | |
---|
32 | ## Default index files |
---|
33 | index index.php index.html; |
---|
34 | |
---|
35 | ## Size Limits |
---|
36 | client_body_buffer_size 64k; |
---|
37 | client_header_buffer_size 32k; |
---|
38 | client_max_body_size 100m; |
---|
39 | large_client_header_buffers 32 32k; |
---|
40 | connection_pool_size 256; |
---|
41 | request_pool_size 4k; |
---|
42 | server_names_hash_bucket_size 512; |
---|
43 | server_names_hash_max_size 8192; |
---|
44 | types_hash_bucket_size 512; |
---|
45 | map_hash_bucket_size 192; |
---|
46 | fastcgi_buffer_size 128k; |
---|
47 | fastcgi_buffers 256 4k; |
---|
48 | fastcgi_busy_buffers_size 256k; |
---|
49 | fastcgi_temp_file_write_size 256k; |
---|
50 | |
---|
51 | ## Timeouts |
---|
52 | client_body_timeout 60; |
---|
53 | client_header_timeout 60; |
---|
54 | send_timeout 60; |
---|
55 | lingering_time 30; |
---|
56 | lingering_timeout 5; |
---|
57 | fastcgi_connect_timeout 60; |
---|
58 | fastcgi_send_timeout 300; |
---|
59 | fastcgi_read_timeout 300; |
---|
60 | |
---|
61 | ## Open File Performance |
---|
62 | open_file_cache max=8000 inactive=30s; |
---|
63 | open_file_cache_valid 60s; |
---|
64 | open_file_cache_min_uses 3; |
---|
65 | open_file_cache_errors on; |
---|
66 | |
---|
67 | ## FastCGI Caching |
---|
68 | fastcgi_cache_path /var/lib/nginx/speed |
---|
69 | levels=2:2:2 |
---|
70 | keys_zone=speed:10m |
---|
71 | inactive=15m |
---|
72 | max_size=3g; |
---|
73 | |
---|
74 | ## General Options |
---|
75 | ignore_invalid_headers on; |
---|
76 | limit_conn_zone $binary_remote_addr zone=limreq:10m; |
---|
77 | recursive_error_pages on; |
---|
78 | reset_timedout_connection on; |
---|
79 | fastcgi_intercept_errors on; |
---|
80 | server_tokens off; |
---|
81 | fastcgi_hide_header 'Link'; |
---|
82 | fastcgi_hide_header 'X-Generator'; |
---|
83 | fastcgi_hide_header 'X-Powered-By'; |
---|
84 | fastcgi_hide_header 'X-Drupal-Cache'; |
---|
85 | |
---|
86 | ## TCP options moved to /etc/nginx/nginx.conf |
---|
87 | |
---|
88 | ## SSL performance |
---|
89 | ssl_session_cache shared:SSL:10m; |
---|
90 | ssl_session_timeout 10m; |
---|
91 | |
---|
92 | ## GeoIP support |
---|
93 | geoip_country /usr/share/GeoIP/GeoIP.dat; |
---|
94 | |
---|
95 | ## Compression |
---|
96 | gzip_buffers 16 8k; |
---|
97 | gzip_comp_level 5; |
---|
98 | gzip_http_version 1.0; |
---|
99 | gzip_min_length 10; |
---|
100 | gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml; |
---|
101 | gzip_vary on; |
---|
102 | gzip_proxied any; |
---|
103 | gzip_static on; |
---|
104 | upload_progress uploads 1m; |
---|
105 | |
---|
106 | ## Log Format |
---|
107 | log_format main '"$proxy_add_x_forwarded_for" $host [$time_local] ' |
---|
108 | '"$request" $status $body_bytes_sent ' |
---|
109 | '$request_length $bytes_sent "$http_referer" ' |
---|
110 | '"$http_user_agent" $request_time "$gzip_ratio"'; |
---|
111 | |
---|
112 | client_body_temp_path /var/lib/nginx/body 1 2; |
---|
113 | access_log /var/log/nginx/access.log main; |
---|
114 | error_log /var/log/nginx/error.log crit; |
---|
115 | |
---|
116 | # Extra configuration from modules: |
---|
117 | ####################################################### |
---|
118 | ### nginx default maps |
---|
119 | ####################################################### |
---|
120 | |
---|
121 | ### |
---|
122 | ### Support separate Boost and Speed Booster caches for various mobile devices. |
---|
123 | ### |
---|
124 | map $http_user_agent $device { |
---|
125 | default normal; |
---|
126 | ~*Nokia|BlackBerry.+MIDP|240x|320x|Palm|NetFront|Symbian|SonyEricsson mobile-other; |
---|
127 | ~*iPhone|iPod|Android|BlackBerry.+AppleWebKit mobile-smart; |
---|
128 | ~*iPad|Tablet mobile-tablet; |
---|
129 | } |
---|
130 | |
---|
131 | ### |
---|
132 | ### Set a cache_uid variable for authenticated users (by @brianmercer and @perusio, fixed by @omega8cc). |
---|
133 | ### |
---|
134 | map $http_cookie $cache_uid { |
---|
135 | default ''; |
---|
136 | ~SESS[[:alnum:]]+=(?<session_id>[[:graph:]]+) $session_id; |
---|
137 | } |
---|
138 | |
---|
139 | ### |
---|
140 | ### Live switch of $key_uri for Speed Booster cache depending on $args. |
---|
141 | ### |
---|
142 | map $request_uri $key_uri { |
---|
143 | default $request_uri; |
---|
144 | ~(?<no_args_uri>[[:graph:]]+)\?(.*)(utm_|__utm|_campaign|gclid|source=|adv=|req=) $no_args_uri; |
---|
145 | } |
---|
146 | |
---|
147 | ### |
---|
148 | ### Set cache expiration depending on the Drupal core version. |
---|
149 | ### |
---|
150 | map $sent_http_x_purge_level $will_expire_in { |
---|
151 | default on-demand; |
---|
152 | ~*5|none 5m; |
---|
153 | } |
---|
154 | |
---|
155 | ### |
---|
156 | ### Deny crawlers. |
---|
157 | ### |
---|
158 | map $http_user_agent $is_crawler { |
---|
159 | default ''; |
---|
160 | ~*HTTrack|BrokenLinkCheck|2009042316.*Firefox.*3\.0\.10|MJ12|HTMLParser|PECL|Automatic|SiteBot|BuzzTrack|Sistrix|Offline|Nutch|Mireo|SWEB|Morfeus|GSLFbot is_crawler; |
---|
161 | } |
---|
162 | |
---|
163 | ### |
---|
164 | ### Deny all known bots/spiders on some URIs. |
---|
165 | ### |
---|
166 | map $http_user_agent $is_bot { |
---|
167 | default ''; |
---|
168 | ~*crawl|bot|spider|tracker|click|parser|google|yahoo|yandex|baidu|bing is_bot; |
---|
169 | } |
---|
170 | |
---|
171 | ### |
---|
172 | ### Deny almost all crawlers under high load. |
---|
173 | ### |
---|
174 | map $http_user_agent $deny_on_high_load { |
---|
175 | default ''; |
---|
176 | ~*crawl|spider|tracker|click|parser|google|yahoo|yandex|baidu|bing deny_on_high_load; |
---|
177 | } |
---|
178 | |
---|
179 | ### |
---|
180 | ### Deny listed requests for security reasons. |
---|
181 | ### |
---|
182 | map $args $is_denied { |
---|
183 | default ''; |
---|
184 | ~*delete.+from|insert.+into|select.+from|union.+select|onload|\.php.+src|system\(.+|document\.cookie|\;|\.\. is_denied; |
---|
185 | } |
---|
186 | |
---|
187 | ####################################################### |
---|
188 | ### nginx default server |
---|
189 | ####################################################### |
---|
190 | |
---|
191 | server { |
---|
192 | limit_conn limreq 32; # like mod_evasive - this allows max 32 simultaneous connections from one IP address |
---|
193 | listen *:80; |
---|
194 | server_name _; |
---|
195 | location / { |
---|
196 | root /var/www/nginx-default; |
---|
197 | index index.html index.htm; |
---|
198 | } |
---|
199 | |
---|
200 | ## chris |
---|
201 | location /nginx_status { |
---|
202 | stub_status on; |
---|
203 | access_log off; |
---|
204 | allow 127.0.0.1; |
---|
205 | allow 81.95.52.103; |
---|
206 | deny all; |
---|
207 | } |
---|
208 | location ~ ^/(status|ping)$ { |
---|
209 | fastcgi_pass 127.0.0.1:9090; |
---|
210 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
---|
211 | fastcgi_intercept_errors on; |
---|
212 | include fastcgi_params; |
---|
213 | access_log off; |
---|
214 | allow 127.0.0.1; |
---|
215 | deny all; |
---|
216 | } |
---|
217 | } |
---|
218 | |
---|
219 | |
---|
220 | ####################################################### |
---|
221 | ### nginx virtual domains |
---|
222 | ####################################################### |
---|
223 | |
---|
224 | # virtual hosts |
---|
225 | include /var/aegir/config/server_master/nginx/pre.d/*; |
---|
226 | include /var/aegir/config/server_master/nginx/platform.d/*; |
---|
227 | include /var/aegir/config/server_master/nginx/vhost.d/*; |
---|
228 | include /var/aegir/config/server_master/nginx/post.d/*; |
---|