|
| 1 | +<?php |
| 2 | + |
| 3 | +$config = <<< END |
| 4 | +
|
| 5 | +server { |
| 6 | +
|
| 7 | + gzip on; |
| 8 | + gzip_http_version 1.0; |
| 9 | + gzip_vary on; |
| 10 | + gzip_comp_level 6; |
| 11 | + gzip_proxied any; |
| 12 | + gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml; |
| 13 | +
|
| 14 | + gzip_buffers 16 8k; |
| 15 | +
|
| 16 | + # ~ nginx performs a regular expression match. |
| 17 | + # ~* removes case sensitivity from the matches |
| 18 | + # ^~) matches literal string and stops processing |
| 19 | + # =) as an argument to location forces an exact match with the path requested and then stops searching for more specific matches. will only match http://ducklington.org/ but not http://ducklington.org/index.html |
| 20 | +
|
| 21 | + listen 80; |
| 22 | + listen 8080; |
| 23 | + server_name example.com www.example.com test.example.com example.test; |
| 24 | +
|
| 25 | + access_log ${'nginx.log.directory'}/example.access.log requestTime; |
| 26 | + error_log ${'nginx.log.directory'}/example.error.log; |
| 27 | +
|
| 28 | + root ${'example.root.directory'}/example; |
| 29 | +
|
| 30 | + client_max_body_size 1m; |
| 31 | + |
| 32 | + rewrite ^/(.*)/$ /$1 permanent; |
| 33 | +
|
| 34 | + error_page 404 /404.html; |
| 35 | + location = /404.html { |
| 36 | + try_files /html/404.html =500; |
| 37 | + } |
| 38 | +
|
| 39 | + # redirect server error pages to the static page /50x.html |
| 40 | + #error_page 500 502 503 504 /50x.html; |
| 41 | +
|
| 42 | + #location = /50x.html { |
| 43 | + # root /usr/share/nginx/html; |
| 44 | + #} |
| 45 | +
|
| 46 | + fastcgi_intercept_errors off; |
| 47 | +
|
| 48 | + # this prevents hidden files (beginning with a period) from being served |
| 49 | + location ~ /\. { access_log off; log_not_found off; deny all; } |
| 50 | +
|
| 51 | + location = /robots.txt { access_log off; log_not_found off; } |
| 52 | + location = /favicon.ico { access_log off; log_not_found off; } |
| 53 | + location ~ /\. { access_log off; log_not_found off; deny all; } |
| 54 | + location ~ ~$ { access_log off; log_not_found off; deny all; } |
| 55 | + |
| 56 | + #This must be the last regular epxression match |
| 57 | + location ~* ^[^\?\&]+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|pdf|ppt|psd|txt|tar|mid|midi|wav|bmp|rtf|js|svg|woff|ttf)$ { |
| 58 | + try_files \$uri /index.php?file=\$1; |
| 59 | +
|
| 60 | + #access_log off; |
| 61 | + expires 7d; |
| 62 | + add_header Pragma public; |
| 63 | + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; |
| 64 | + } |
| 65 | + |
| 66 | + location ~ ^/(www-status|ping)$ { |
| 67 | + if ( \$remote_addr != 127.0.0.1 ) { return 444;} |
| 68 | + access_log off; |
| 69 | + allow 127.0.0.1; |
| 70 | + deny all; |
| 71 | + fastcgi_param QUERY_STRING \$query_string; |
| 72 | + include ${'example.root.directory'}/data/conf/fastcgi.conf; |
| 73 | + fastcgi_pass unix:${'phpfpm.fullsocketpath'}; |
| 74 | + } |
| 75 | +
|
| 76 | + location / { |
| 77 | + try_files \$uri /index.php =404; |
| 78 | + fastcgi_param QUERY_STRING \$query_string; |
| 79 | + fastcgi_pass unix:${'phpfpm.fullsocketpath'}; |
| 80 | + include ${'example.root.directory'}/data/conf/fastcgi.conf; |
| 81 | + } |
| 82 | +} |
| 83 | +
|
| 84 | +END; |
| 85 | + |
| 86 | +return $config; |
0 commit comments