Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################################################
- ### nginx.conf site standard vhost include start
- #######################################################
- ###
- ### Deny crawlers without 403 response.
- ###
- if ($is_crawler) {
- return 444;
- }
- ###
- ### Deny not compatible request methods without 405 response.
- ###
- if ( $request_method !~ ^(?:GET|HEAD|POST)$ ) {
- return 444;
- }
- ###
- ### Deny listed requests for security reasons without 403 response.
- ###
- location ~* (?:delete.+from|insert.+into|select.+from|union.+select|onload|\.php.+src|system\(.+|iframe|document\.cookie|\;|\.\.) {
- return 444;
- }
- ###
- ### If favicon else return error 204.
- ###
- location ^~ /favicon.ico {
- access_log off;
- log_not_found off;
- expires 30d;
- try_files /sites/$host/files/favicon.ico $uri =204;
- }
- ###
- ### Support for http://drupal.org/project/robotstxt module
- ### and static file in the sites/domain/files directory.
- ###
- location ~* /robots.txt {
- access_log off;
- try_files /sites/$host/files/robots.txt $uri @cache;
- }
- ###
- ### Allow local access to support wget method in Aegir settings
- ### for running sites cron.
- ###
- location ^~ /cron.php {
- access_log off;
- allow 173.230.my.ip;
- deny all;
- try_files $uri =404;
- fastcgi_pass 127.0.0.1:9000; ### php-fpm listening on port 9000
- }
- ###
- ### Send search to php-fpm early so searching for node.js will work.
- ### Deny bots on search uri without 403 response.
- ###
- location ~* /search {
- if ($is_bot) {
- return 444;
- }
- try_files $uri @cache;
- }
- ###
- ### Upload progress support.
- ### http://drupal.org/project/filefield_nginx_progress
- ### http://github.com/masterzen/nginx-upload-progress-module
- ###
- location ~ (?:.*)/x-progress-id:(?:\w*) {
- access_log off;
- rewrite ^(.*)/x-progress-id:(\w*) $1?X-Progress-ID=$2;
- }
- location ^~ /progress {
- access_log off;
- report_uploads uploads;
- }
- ###
- ### Deny access to Hostmaster web/db server node.
- ### It is still possible to edit or break web/db server
- ### node at /node/2/edit, if you know what are you doing.
- ###
- location ^~ /hosting/c/server_master {
- access_log off;
- rewrite ^ $scheme://$host/hosting/sites permanent;
- }
- ###
- ### Deny access to Hostmaster db server node.
- ### It is still possible to edit or break db server
- ### node at /node/4/edit, if you know what are you doing.
- ###
- location ^~ /hosting/c/server_localhost {
- access_log off;
- rewrite ^ $scheme://$host/hosting/sites permanent;
- }
- ###
- ### Fix for Aegir & .info .pl domain extensions.
- ###
- location ~* /hosting {
- access_log off;
- try_files $uri @cache;
- }
- ###
- ### Deny php env display d5.
- ###
- location ^~ /admin/logs/status/ {
- access_log off;
- rewrite ^ $scheme://$host/admin/logs/status permanent;
- }
- ###
- ### Deny cache details display.
- ###
- location ^~ /admin/reports/cache {
- access_log off;
- rewrite ^ $scheme://$host/admin/reports/status permanent;
- }
- ###
- ### Deny php/sql env display d6 & d7.
- ###
- location ~* /admin/reports/status/(?:php|sql) {
- access_log off;
- rewrite ^ $scheme://$host/admin/reports/status permanent;
- }
- ###
- ### Support for backup_migrate module download/restore/delete actions.
- ###
- location ~* /admin {
- if ($is_bot) {
- return 444;
- }
- access_log off;
- try_files $uri @cache;
- }
- ###
- ### Deny listed requests for security reasons without 403 response.
- ###
- location ~* (/\..*|settings\.php$|\.(?:git|htaccess|engine|inc|info|install|module|profile|pl|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)$|^(?:Entries.*|Repository|Root|Tag|Template))$ {
- return 444;
- }
- ###
- ### Deny some not supported URI like cgi-bin on the Nginx level.
- ###
- location ~* (?:cgi-bin|vti-bin|wp-content) {
- access_log off;
- return 444;
- }
- ###
- ### Deny bots on some weak modules uri without 403 response.
- ###
- location ~* (?:calendar|event|validation) {
- if ($is_bot) {
- return 444;
- }
- try_files $uri @cache;
- }
- ###
- ### Responsive Images support.
- ### http://drupal.org/project/responsive_images
- ###
- location ~* \.r\.(?:jpe?g|png|gif) {
- if ( $http_cookie ~* "rwdimgsize=large" ) {
- rewrite ^/(.*)/mobile/(.*)\.r(\.(?:jpe?g|png|gif))$ /$1/desktop/$2$3 last;
- }
- rewrite ^/(.*)\.r(\.(?:jpe?g|png|gif))$ /$1$2 last;
- access_log off;
- add_header X-Header "RI Generator 1.0";
- try_files $uri @drupal;
- }
- ###
- ### Imagecache and imagecache_external support.
- ###
- location ~* /(?:external|system|files/imagecache|files/styles)/ {
- access_log off;
- log_not_found off;
- expires 30d;
- # fix common problems with old paths after import from standalone to Aegir multisite
- rewrite ^/sites/(.*)/files/imagecache/(.*)/sites/default/files/(.*)$ /sites/$host/files/imagecache/$2/$3 last;
- rewrite ^/files/imagecache/(.*)$ /sites/$host/files/imagecache/$1 last;
- rewrite ^/files/styles/(.*)$ /sites/$host/files/styles/$1 last;
- add_header X-Header "IC Generator 1.0";
- try_files $uri @drupal;
- }
- ###
- ### Deny direct access to backups.
- ###
- location ~* ^/sites/.*/files/backup_migrate/ {
- access_log off;
- deny all;
- }
- ###
- ### Include local configuration override if exists.
- ###
- include /data/disk/EDIT_USER/config/server_master/nginx/post.d/nginx_vhost_include*;
- ###
- ### Private downloads are always sent to the drupal backend.
- ### Note: this location doesn't work with X-Accel-Redirect.
- ###
- location ~* ^/sites/.*/files/private/ {
- access_log off;
- rewrite ^/sites/.*/files/private/(.*)$ $scheme://$host/system/files/private/$1 permanent;
- add_header X-Header "Private Generator 1.0a";
- try_files $uri @drupal;
- }
- ###
- ### Deny direct access to private downloads in sites/domain/private.
- ### Note: this location works with X-Accel-Redirect.
- ###
- location ~* ^/sites/.*/private/ {
- access_log off;
- internal;
- }
- ###
- ### Deny direct access to private downloads also for short, rewritten URLs.
- ### Note: this location works with X-Accel-Redirect.
- ###
- location ~* /files/private/ {
- access_log off;
- internal;
- }
- ###
- ### Advagg_css and Advagg_js support.
- ###
- location ~* files/advagg_(?:css|js)/ {
- access_log off;
- expires 365d;
- limit_conn gulag 50;
- rewrite ^/files/advagg_(.*)/(.*)$ /sites/$host/files/advagg_$1/$2 last;
- add_header Pragma "";
- add_header Accept-Ranges "";
- add_header Cache-Control "public";
- add_header X-Header "AdvAgg Generator 1.0";
- try_files $uri @drupal;
- }
- ###
- ### Make css files compatible with boost caching.
- ###
- location ~* \.css$ {
- if ( $request_method !~ ^(?:GET|HEAD)$ ) {
- return 405;
- }
- if ( $http_cookie ~ "DRUPAL_UID" ) {
- return 405;
- }
- error_page 405 = @uncached;
- access_log off;
- tcp_nodelay off;
- expires max; #if using aggregator
- add_header X-Header "Boost Citrus 2.1";
- try_files /cache/perm/$host${uri}_.css $uri =404;
- }
- ###
- ### Make js files compatible with boost caching.
- ###
- location ~* \.(?:js|htc)$ {
- if ( $request_method !~ ^(?:GET|HEAD)$ ) {
- return 405;
- }
- if ( $http_cookie ~ "DRUPAL_UID" ) {
- return 405;
- }
- error_page 405 = @uncached;
- access_log off;
- tcp_nodelay off;
- expires max; # if using aggregator
- add_header X-Header "Boost Citrus 2.2";
- try_files /cache/perm/$host${uri}_.js $uri =404;
- }
- ###
- ### Make json compatible with boost caching.
- ###
- location ~* \.json$ {
- if ( $request_method !~ ^(?:GET|HEAD)$ ) {
- return 405;
- }
- if ( $http_cookie ~ "DRUPAL_UID" ) {
- return 405;
- }
- error_page 405 = @uncached;
- access_log off;
- tcp_nodelay off;
- expires max; ### if using aggregator
- add_header X-Header "Boost Citrus 2.3";
- try_files /cache/$device/$host${uri}_.json $uri =404;
- }
- ###
- ### Helper location to bypass boost static files cache for logged in users.
- ###
- location @uncached {
- access_log off;
- expires max; # max if using aggregator, otherwise sane expire time
- }
- ###
- ### Serve & no-log static files & images directly,
- ### without all standard drupal rewrites, php-fpm etc.
- ###
- location ~* ^.+\.(?:jpe?g|gif|png|ico|bmp|svg|swf|pdf|docx?|xlsx?|pptx?|tiff?|txt|rtf|cgi|bat|pl|dll|aspx?|exe|class|otf|ttf|woff)$ {
- access_log off;
- tcp_nodelay off;
- expires 30d;
- # allow files/images/downloads to be accessed without /sites/fqdn/
- rewrite ^/files/(.*)$ /sites/$host/files/$1 last;
- rewrite ^/images/(.*)$ /sites/$host/files/images/$1 last;
- rewrite ^/downloads/(.*)$ /sites/$host/files/downloads/$1 last;
- rewrite ^/.+/sites/.+/files/(.*)$ /sites/$host/files/$1 last;
- try_files $uri =404;
- }
- ###
- ### Serve & log bigger media/static/archive files directly,
- ### without all standard drupal rewrites, php-fpm etc.
- ###
- location ~* ^.+\.(?:avi|mpe?g|mov|wmv|mp3|mp4|m4a|ogg|ogv|flv|wav|midi|zip|tar|t?gz|rar)$ {
- expires 30d;
- tcp_nodelay off;
- # allow files/downloads to be accessed without /sites/fqdn/
- rewrite ^/files/(.*)$ /sites/$host/files/$1 last;
- rewrite ^/downloads/(.*)$ /sites/$host/files/downloads/$1 last;
- rewrite ^/.+/sites/.+/files/(.*)$ /sites/$host/files/$1 last;
- try_files $uri =404;
- }
- ###
- ### Serve & no-log some static files as is, without forcing default_type.
- ###
- location ~* /(?:cross-?domain)\.xml$ {
- access_log off;
- tcp_nodelay off;
- expires 30d;
- add_header X-Header "XML Generator 1.0";
- try_files $uri =404;
- }
- ###
- ### Allow some known php files (like serve.php in the ad module).
- ###
- location ~* ^/sites/.*/(?:modules|libraries)/(?:contrib/)?(?:ad|tinybrowser|f?ckeditor|tinymce|wysiwyg_spellcheck|ecc|civicrm|fbconnect)/.*\.php$ {
- access_log off;
- try_files $uri =404;
- fastcgi_pass 127.0.0.1:9000; ### php-fpm listening on port 9000
- }
- ###
- ### Serve & no-log static helper files used in some wysiwyg editors.
- ###
- location ~* ^/sites/.*/(?:modules|libraries)/(?:tinybrowser|f?ckeditor|tinymce)/.*\.(?:html?|xml)$ {
- access_log off;
- tcp_nodelay off;
- expires 30d;
- try_files $uri =404;
- }
- ###
- ### Serve & no-log any not specified above static files directly.
- ###
- location ~* ^/sites/.*/files/ {
- access_log off;
- tcp_nodelay off;
- expires 30d;
- try_files $uri =404;
- }
- ###
- ### Make feeds compatible with boost caching and set correct mime type.
- ###
- location ~* \.xml$ {
- if ( $request_method !~ ^(?:GET|HEAD)$ ) {
- return 405;
- }
- if ( $http_cookie ~ "DRUPAL_UID" ) {
- return 405;
- }
- error_page 405 = @drupal;
- access_log off;
- add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
- add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
- add_header X-Header "Boost Citrus 2.4";
- charset utf-8;
- types { }
- default_type application/rss+xml;
- try_files /cache/$device/$host${uri}_.xml /cache/$device/$host${uri}_.html $uri @drupal;
- }
- ###
- ### Make feeds compatible with Boost caching and set correct mime type.
- ###
- location ~* /feed {
- if ( $request_method !~ ^(?:GET|HEAD)$ ) {
- return 405;
- }
- if ( $http_cookie ~ "DRUPAL_UID" ) {
- return 405;
- }
- error_page 405 = @drupal;
- access_log off;
- add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
- add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
- add_header X-Header "Boost Citrus 2.5";
- charset utf-8;
- types { }
- default_type application/rss+xml;
- try_files /cache/$device/$host${uri}_.xml /cache/$device/$host${uri}_.html $uri @drupal;
- }
- ###
- ### Deny phpinfo details display.
- ###
- location ~* /devel/(?:phpinfo|php) {
- access_log off;
- rewrite ^ $scheme://$host/admin/reports/status permanent;
- }
- ###
- ### Deny bots on never cached uri without 403 response.
- ###
- location ~* ^/(?:.*/)?(?:user|cart|checkout|logout) {
- if ($is_bot) {
- return 444;
- }
- access_log off;
- try_files $uri @cache;
- }
- ###
- ### Deny bots on never cached uri without 403 response - og compatible.
- ###
- location ~* /(?:node/[0-9]+/edit|node/add|comment/reply|approve|users) {
- if ($is_bot) {
- return 444;
- }
- access_log off;
- try_files $uri @cache;
- }
- ###
- ### Catch all unspecified requests.
- ###
- location / {
- if ( $http_user_agent ~* wget ) {
- return 444;
- }
- try_files $uri @cache;
- }
- ###
- ### Boost compatible cache check.
- ###
- location @cache {
- if ( $request_method !~ ^(?:GET|HEAD)$ ) {
- return 405;
- }
- if ( $http_cookie ~ "DRUPAL_UID" ) {
- return 405;
- }
- error_page 405 = @drupal;
- add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
- add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
- add_header X-Header "Boost Citrus 1.9";
- charset utf-8;
- try_files /cache/$device/$host${uri}_$args.html @drupal;
- }
- ###
- ### Send all not cached requests to drupal with clean URLs support.
- ###
- location @drupal {
- rewrite ^/(.*)$ /index.php?q=$1 last;
- }
- ###
- ### Send all non-static requests to php-fpm, restricted to known php file.
- ###
- location ~* ^/index\.php$ {
- add_header X-Header "Barracuda Engine 1.0 Turbo";
- add_header X-Device "$device";
- try_files $uri =404; ### check for existence of php file first
- fastcgi_pass 127.0.0.1:9000; ### php-fpm listening on port 9000
- track_uploads uploads 60s; ### required for upload progress
- ###
- ### use Nginx cache for all visitors
- ###
- if ( $request_method ~ ^(?:HEAD|POST)$ ) {
- set $nocache "Y";
- }
- fastcgi_cache speed;
- fastcgi_cache_min_uses 1;
- fastcgi_cache_key "$device$host$key_uri$cookie_OctopusCacheID";
- fastcgi_cache_valid 200 301 302 50m;
- fastcgi_cache_valid 404 1m;
- fastcgi_ignore_headers Cache-Control Expires;
- fastcgi_pass_header Set-Cookie;
- fastcgi_pass_header X-Accel-Expires;
- fastcgi_pass_header X-Accel-Redirect;
- fastcgi_no_cache $cookie_OctopusNoCacheID;
- fastcgi_no_cache $nocache;
- fastcgi_cache_bypass $cookie_OctopusNoCacheID;
- fastcgi_cache_bypass $nocache;
- fastcgi_cache_use_stale error timeout invalid_header http_500 http_503 updating;
- }
- ###
- ### Send other known php requests/files to php-fpm without any caching.
- ###
- location ~* ^/(?:boost_stats|update|authorize|rtoc|xmlrpc)\.php$ {
- access_log off;
- try_files $uri =404; ### check for existence of php file first
- fastcgi_pass 127.0.0.1:9000; ### php-fpm listening on port 9000
- }
- ###
- ### Deny access to any not listed above php files.
- ###
- location ~* ^.+\.php$ {
- deny all;
- }
- #######################################################
- ### nginx.conf site standard vhost include end
- #######################################################
Advertisement
Add Comment
Please, Sign In to add comment