summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarracuda Team2014-11-16 00:46:27 (GMT)
committerBarracuda Team2014-11-16 00:46:27 (GMT)
commit987b0c77733cb1bf92c44a8bd1d0832987f2d1e3 (patch)
tree319b28a87face63fa27d96649cf1b43e96c9f030
parentd4883053e51a9bfff9fd29170dc823bcf4b0a268 (diff)
parent20e487086e22537e5dc9348273e29f3b359dc80c (diff)
Merge branch 'refs/heads/6.x-2.x' into 2.3.x-devBOA-2.3.6
-rw-r--r--http/Provision/Config/Nginx/Ssl/vhost_ssl.tpl.php35
-rw-r--r--http/Provision/Config/Nginx/subdir.tpl.php19
-rw-r--r--http/Provision/Config/Nginx/vhost.tpl.php2
3 files changed, 47 insertions, 9 deletions
diff --git a/http/Provision/Config/Nginx/Ssl/vhost_ssl.tpl.php b/http/Provision/Config/Nginx/Ssl/vhost_ssl.tpl.php
index 74ae15b..9dd3057 100644
--- a/http/Provision/Config/Nginx/Ssl/vhost_ssl.tpl.php
+++ b/http/Provision/Config/Nginx/Ssl/vhost_ssl.tpl.php
@@ -5,7 +5,19 @@
<?php foreach ($this->aliases as $alias_url): ?>
server {
listen <?php print "{$ip_address}:{$http_ssl_port}"; ?>;
- server_name <?php print $alias_url; ?>;
+<?php
+ // if we use redirections, we need to change the redirection
+ // target to be the original site URL ($this->uri instead of
+ // $alias_url)
+ if ($this->redirection && $alias_url == $this->redirection) {
+ $this->uri = str_replace('/', '.', $this->uri);
+ print " server_name {$this->uri};\n";
+ }
+ else {
+ $alias_url = str_replace('/', '.', $alias_url);
+ print " server_name {$alias_url};\n";
+ }
+?>
ssl on;
ssl_certificate <?php print $ssl_cert; ?>;
ssl_certificate_key <?php print $ssl_cert_key; ?>;
@@ -13,13 +25,15 @@ server {
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 70;
- rewrite ^ $scheme://<?php print $this->uri; ?>$request_uri? permanent;
+ rewrite ^ $scheme://<?php print $this->redirection; ?>$request_uri? permanent;
}
<?php endforeach; ?>
<?php endif ?>
server {
include fastcgi_params;
+ fastcgi_param MAIN_SITE_NAME <?php print $this->uri; ?>;
+ set $main_site_name "<?php print $this->uri; ?>";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_param db_type <?php print urlencode($db_type); ?>;
@@ -29,7 +43,22 @@ server {
fastcgi_param db_host <?php print urlencode($db_host); ?>;
fastcgi_param db_port <?php print urlencode($db_port); ?>;
listen <?php print "{$ip_address}:{$http_ssl_port}"; ?>;
- server_name <?php print $this->uri; ?><?php if (!$this->redirection && is_array($this->aliases)) : foreach ($this->aliases as $alias_url) : if (trim($alias_url)) : ?> <?php print $alias_url; ?><?php endif; endforeach; endif; ?>;
+ server_name <?php
+ // this is the main vhost, so we need to put the redirection
+ // target as the hostname (if it exists) and not the original URL
+ // ($this->uri)
+ if ($this->redirection) {
+ print str_replace('/', '.', $this->redirection);
+ } else {
+ print $this->uri;
+ }
+ if (!$this->redirection && is_array($this->aliases)) {
+ foreach ($this->aliases as $alias_url) {
+ if (trim($alias_url)) {
+ print " " . str_replace('/', '.', $alias_url);
+ }
+ }
+ } ?>;
root <?php print "{$this->root}"; ?>;
ssl on;
ssl_certificate <?php print $ssl_cert; ?>;
diff --git a/http/Provision/Config/Nginx/subdir.tpl.php b/http/Provision/Config/Nginx/subdir.tpl.php
index 3ab06e7..e912d7d 100644
--- a/http/Provision/Config/Nginx/subdir.tpl.php
+++ b/http/Provision/Config/Nginx/subdir.tpl.php
@@ -29,6 +29,15 @@ if (!$satellite_mode && $server->satellite_mode) {
#######################################################
###
+### Use the main site name if available, instead of
+### potentially virtual server_name when alias is set
+### as redirection target. See #2358977 for details.
+###
+if ($main_site_name = '') {
+ set $main_site_name "$server_name";
+}
+
+###
### Master location for subdir support (start)
###
location ^~ /<?php print $subdir; ?> {
@@ -136,7 +145,7 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
access_log off;
log_not_found off;
expires 30d;
- try_files /sites/$server_name/files/favicon.ico /sites/$host/files/favicon.ico /favicon.ico $uri =204;
+ try_files /sites/$main_site_name/files/favicon.ico /sites/$host/files/favicon.ico /favicon.ico $uri =204;
}
###
@@ -147,9 +156,9 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
access_log off;
log_not_found off;
<?php if ($nginx_config_mode == 'extended'): ?>
- try_files /sites/$server_name/files/$host.robots.txt /sites/$server_name/files/robots.txt /sites/$host/files/robots.txt /robots.txt $uri @cache_<?php print $subdir; ?>;
+ try_files /sites/$main_site_name/files/$host.robots.txt /sites/$main_site_name/files/robots.txt /sites/$host/files/robots.txt /robots.txt $uri @cache_<?php print $subdir; ?>;
<?php else: ?>
- try_files /sites/$server_name/files/$host.robots.txt /sites/$server_name/files/robots.txt /sites/$host/files/robots.txt /robots.txt $uri @drupal_<?php print $subdir; ?>;
+ try_files /sites/$main_site_name/files/$host.robots.txt /sites/$main_site_name/files/robots.txt /sites/$host/files/robots.txt /robots.txt $uri @drupal_<?php print $subdir; ?>;
<?php endif; ?>
}
@@ -609,7 +618,7 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
###
location ~* ^/<?php print $subdir; ?>/(sites/.*/files/.*) {
root <?php print "{$this->root}"; ?>;
- rewrite ^/<?php print $subdir; ?>/sites/(.*)$ /sites/$server_name/$1 last;
+ rewrite ^/<?php print $subdir; ?>/sites/(.*)$ /sites/$main_site_name/$1 last;
access_log off;
tcp_nodelay off;
expires 30d;
@@ -794,7 +803,7 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
add_header X-Speed-Cache-Key "$key_uri";
add_header X-NoCache "$nocache_details";
add_header X-This-Proto "$http_x_forwarded_proto";
- add_header X-Server-Name "$server_name";
+ add_header X-Server-Name "$main_site_name";
<?php endif; ?>
root <?php print "{$this->root}"; ?>;
diff --git a/http/Provision/Config/Nginx/vhost.tpl.php b/http/Provision/Config/Nginx/vhost.tpl.php
index a5d804b..54f336c 100644
--- a/http/Provision/Config/Nginx/vhost.tpl.php
+++ b/http/Provision/Config/Nginx/vhost.tpl.php
@@ -60,7 +60,7 @@ if ($this->redirection || $ssl_redirection) {
}
elseif ($ssl_redirection && $this->redirection) {
// redirect all aliases + main uri to the main https uri.
- print "\n rewrite ^ https://{$this->uri}\$request_uri? permanent;\n";
+ print "\n rewrite ^ https://{$this->redirection}\$request_uri? permanent;\n";
}
elseif (!$ssl_redirection && $this->redirection) {
print " include " . $server->include_path . "/nginx_vhost_common.conf;\n";