...
 
Commits (3)
......@@ -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; ?>;
......
......@@ -28,6 +28,15 @@ if (!$satellite_mode && $server->satellite_mode) {
<?php endif; ?>
#######################################################
###
### 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)
###
......@@ -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}"; ?>;
......
......@@ -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";
......