Commit 45d7418f authored by omega8cc's avatar omega8cc

Nginx: Sync configuration improvements.

parent 98cc46ba
......@@ -682,6 +682,38 @@ location @uncached {
### Map /files/ shortcut early to avoid overrides in other locations.
###
location ^~ /files/ {
###
### Sub-location to support files/styles with short URIs.
###
location ~* /files/styles/(.*)$ {
access_log off;
log_not_found off;
expires 30d;
<?php if ($nginx_config_mode == 'extended'): ?>
set $nocache_details "Skip";
<?php endif; ?>
rewrite ^/files/(.*)$ /sites/$main_site_name/files/$1 last;
try_files /sites/$main_site_name/files/styles/$1 $uri @drupal;
}
###
### Sub-location to support files/imagecache with short URIs.
###
location ~* /files/imagecache/(.*)$ {
access_log off;
log_not_found off;
expires 30d;
<?php if ($nginx_config_mode == 'extended'): ?>
# fix common problems with old paths after import from standalone to Aegir multisite
rewrite ^/files/imagecache/(.*)/sites/default/files/(.*)$ /sites/$main_site_name/files/imagecache/$1/$2 last;
rewrite ^/files/imagecache/(.*)/files/(.*)$ /sites/$main_site_name/files/imagecache/$1/$2 last;
set $nocache_details "Skip";
<?php endif; ?>
rewrite ^/files/(.*)$ /sites/$main_site_name/files/$1 last;
try_files /sites/$main_site_name/files/imagecache/$1 $uri @drupal;
}
location ~* ^.+\.(?:pdf|jpe?g|gif|png|ico|bmp|svg|swf|docx?|xlsx?|pptx?|tiff?|txt|rtf|cgi|bat|pl|dll|class|otf|ttf|woff|eot|less|avi|mpe?g|mov|wmv|mp3|ogg|ogv|wav|midi|zip|tar|t?gz|rar|dmg|exe|apk|pxl|ipa)$ {
expires 30d;
tcp_nodelay off;
......
......@@ -28,7 +28,7 @@ server {
rewrite ^ $scheme://<?php print $this->redirection; ?>$request_uri? permanent;
}
<?php endforeach; ?>
<?php endif ?>
<?php endif; ?>
server {
include fastcgi_params;
......
......@@ -206,7 +206,7 @@ map $http_user_agent $device {
### Set a cache_uid variable for authenticated users (by @brianmercer and @perusio, fixed by @omega8cc).
###
map $http_cookie $cache_uid {
default '';
default '';
~SESS[[:alnum:]]+=(?<session_id>[[:graph:]]+) $session_id;
}
......@@ -223,8 +223,9 @@ map $request_uri $key_uri {
###
map $http_user_agent $is_crawler {
default '';
~*HTTrack|BrokenLinkCheck|2009042316.*Firefox.*3\.0\.10|MJ12|HTMLParser|PECL|Automatic|CCBot is_crawler;
~*SiteBot|BuzzTrack|Sistrix|Offline|Nutch|Mireo|SWEB|Morfeus|GSLFbot|HiScan|Riddler|DBot is_crawler;
~*HTTrack|BrokenLinkCheck|2009042316.*Firefox.*3\.0\.10|MJ12|HTMLParser is_crawler;
~*SiteBot|PECL|Automatic|CCBot|BuzzTrack|Sistrix|Offline|Nutch|Mireo is_crawler;
~*SWEB|Morfeus|GSLFbot|HiScan|Riddler|DBot|SEOkicks|PChomebot is_crawler;
}
###
......@@ -240,7 +241,7 @@ map $http_referer $is_botnet {
### Deny all known bots/spiders on some URIs.
###
map $http_user_agent $is_bot {
default '';
default '';
~*crawl|bot|spider|tracker|click|parser|google|yahoo|yandex|baidu|bing is_bot;
}
......@@ -256,7 +257,7 @@ map $http_user_agent $deny_on_high_load {
### Deny listed requests for security reasons.
###
map $args $is_denied {
default '';
default '';
~*delete.+from|insert.+into|select.+from|union.+select|onload|\.php.+src|system\(.+|document\.cookie|\;|\.\. is_denied;
}
<?php endif; ?>
......
......@@ -417,6 +417,59 @@ location ^~ /<?php print $subdir; ?> {
}
<?php endif; ?>
###
### Map /<?php print $subdir; ?>/files/ shortcut early to avoid overrides in other locations.
###
location ^~ /<?php print $subdir; ?>/files/ {
###
### Sub-location to support files/styles with short URIs.
###
location ~* /<?php print $subdir; ?>/files/styles/(.*)$ {
access_log off;
log_not_found off;
expires 30d;
<?php if ($nginx_config_mode == 'extended'): ?>
set $nocache_details "Skip";
<?php endif; ?>
rewrite ^/<?php print $subdir; ?>/files/(.*)$ /<?php print $subdir; ?>/sites/$main_site_name/files/$1 last;
try_files /<?php print $subdir; ?>/sites/$main_site_name/files/styles/$1 $uri @drupal_<?php print $subdir; ?>;
}
###
### Sub-location to support files/imagecache with short URIs.
###
location ~* /<?php print $subdir; ?>/files/imagecache/(.*)$ {
access_log off;
log_not_found off;
expires 30d;
<?php if ($nginx_config_mode == 'extended'): ?>
# fix common problems with old paths after import from standalone to Aegir multisite
rewrite ^/<?php print $subdir; ?>/files/imagecache/(.*)/sites/default/files/(.*)$ /<?php print $subdir; ?>/sites/$main_site_name/files/imagecache/$1/$2 last;
rewrite ^/<?php print $subdir; ?>/files/imagecache/(.*)/files/(.*)$ /<?php print $subdir; ?>/sites/$main_site_name/files/imagecache/$1/$2 last;
set $nocache_details "Skip";
<?php endif; ?>
rewrite ^/<?php print $subdir; ?>/files/(.*)$ /<?php print $subdir; ?>/sites/$main_site_name/files/$1 last;
try_files /<?php print $subdir; ?>/sites/$main_site_name/files/imagecache/$1 $uri @drupal_<?php print $subdir; ?>;
}
location ~* ^.+\.(?:pdf|jpe?g|gif|png|ico|bmp|svg|swf|docx?|xlsx?|pptx?|tiff?|txt|rtf|cgi|bat|pl|dll|class|otf|ttf|woff|eot|less|avi|mpe?g|mov|wmv|mp3|ogg|ogv|wav|midi|zip|tar|t?gz|rar|dmg|exe|apk|pxl|ipa)$ {
expires 30d;
tcp_nodelay off;
access_log off;
log_not_found off;
add_header Access-Control-Allow-Origin *;
rewrite ^/<?php print $subdir; ?>/files/(.*)$ /<?php print $subdir; ?>/sites/$main_site_name/files/$1 last;
try_files $uri =404;
}
<?php if ($nginx_config_mode == 'extended'): ?>
try_files $uri @cache_<?php print $subdir; ?>;
<?php else: ?>
try_files $uri @drupal_<?php print $subdir; ?>;
<?php endif; ?>
}
###
### Imagecache and imagecache_external support.
###
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment