Commit fed06822 authored by omega8cc's avatar omega8cc

Issue #2373923 by griz - https redirect problem with Nginx (fix tested)

parent 3f7b7f09
...@@ -5,7 +5,19 @@ ...@@ -5,7 +5,19 @@
<?php foreach ($this->aliases as $alias_url): ?> <?php foreach ($this->aliases as $alias_url): ?>
server { server {
listen <?php print "{$ip_address}:{$http_ssl_port}"; ?>; 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 on;
ssl_certificate <?php print $ssl_cert; ?>; ssl_certificate <?php print $ssl_cert; ?>;
ssl_certificate_key <?php print $ssl_cert_key; ?>; ssl_certificate_key <?php print $ssl_cert_key; ?>;
...@@ -13,13 +25,15 @@ server { ...@@ -13,13 +25,15 @@ server {
ssl_ciphers RC4:HIGH:!aNULL:!MD5; ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on; ssl_prefer_server_ciphers on;
keepalive_timeout 70; keepalive_timeout 70;
rewrite ^ $scheme://<?php print $this->uri; ?>$request_uri? permanent; rewrite ^ $scheme://<?php print $this->redirection; ?>$request_uri? permanent;
} }
<?php endforeach; ?> <?php endforeach; ?>
<?php endif ?> <?php endif ?>
server { server {
include fastcgi_params; 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 SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on; fastcgi_param HTTPS on;
fastcgi_param db_type <?php print urlencode($db_type); ?>; fastcgi_param db_type <?php print urlencode($db_type); ?>;
...@@ -29,7 +43,22 @@ server { ...@@ -29,7 +43,22 @@ server {
fastcgi_param db_host <?php print urlencode($db_host); ?>; fastcgi_param db_host <?php print urlencode($db_host); ?>;
fastcgi_param db_port <?php print urlencode($db_port); ?>; fastcgi_param db_port <?php print urlencode($db_port); ?>;
listen <?php print "{$ip_address}:{$http_ssl_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}"; ?>; root <?php print "{$this->root}"; ?>;
ssl on; ssl on;
ssl_certificate <?php print $ssl_cert; ?>; ssl_certificate <?php print $ssl_cert; ?>;
......
...@@ -60,7 +60,7 @@ if ($this->redirection || $ssl_redirection) { ...@@ -60,7 +60,7 @@ if ($this->redirection || $ssl_redirection) {
} }
elseif ($ssl_redirection && $this->redirection) { elseif ($ssl_redirection && $this->redirection) {
// redirect all aliases + main uri to the main https uri. // 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) { elseif (!$ssl_redirection && $this->redirection) {
print " include " . $server->include_path . "/nginx_vhost_common.conf;\n"; print " include " . $server->include_path . "/nginx_vhost_common.conf;\n";
......
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