Commit ba16187c authored by omega8cc's avatar omega8cc

Nginx: Use faster 301/302 redirects

parent d51dee44
......@@ -317,7 +317,7 @@ location ^~ /hosting/c/server_master {
return 403;
}
access_log off;
rewrite ^ $scheme://$host/hosting/sites permanent;
return 301 $scheme://$host/hosting/sites;
}
###
......@@ -333,7 +333,7 @@ location ^~ /hosting/c/server_localhost {
return 403;
}
access_log off;
rewrite ^ $scheme://$host/hosting/sites permanent;
return 301 $scheme://$host/hosting/sites;
}
<?php endif; ?>
......@@ -367,7 +367,7 @@ location ^~ /hosting {
###
location ^~ /admin/settings/performance/cache-backend {
access_log off;
rewrite ^ $scheme://$host/admin/settings/performance permanent;
return 301 $scheme://$host/admin/settings/performance;
}
###
......@@ -375,7 +375,7 @@ location ^~ /admin/settings/performance/cache-backend {
###
location ^~ /admin/config/development/performance/redis {
access_log off;
rewrite ^ $scheme://$host/admin/config/development/performance permanent;
return 301 $scheme://$host/admin/config/development/performance;
}
<?php endif; ?>
......@@ -1156,7 +1156,7 @@ location @drupal {
###
location @nobots {
if ($is_bot) {
rewrite ^ $scheme://$host$request_uri? permanent;
return 301 $scheme://$host$request_uri;
}
###
### Return 404 on special PHP URLs to avoid revealing version used,
......
......@@ -22,7 +22,7 @@ server {
ssl_certificate <?php print $ssl_cert; ?>;
ssl_certificate_key <?php print $ssl_cert_key; ?>;
keepalive_timeout 70;
rewrite ^ $scheme://<?php print $this->redirection; ?>$request_uri? permanent;
return 301 $scheme://<?php print $this->redirection; ?>$request_uri;
}
<?php endforeach; ?>
<?php endif; ?>
......
......@@ -16,7 +16,7 @@ server {
index index.html index.htm;
### Do not reveal Aegir front-end URL here.
<?php else: ?>
rewrite ^ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>? redirect;
return 302 <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>;
<?php endif; ?>
ssl on;
ssl_certificate <?php print $ssl_cert; ?>;
......
......@@ -352,7 +352,7 @@ location ^~ /<?php print $subdir; ?> {
###
location ^~ /<?php print $subdir; ?>/admin/settings/performance/cache-backend {
access_log off;
rewrite ^ $scheme://$host/<?php print $subdir; ?>/admin/settings/performance permanent;
return 301 $scheme://$host/<?php print $subdir; ?>/admin/settings/performance;
}
###
......@@ -360,7 +360,7 @@ location ^~ /<?php print $subdir; ?> {
###
location ^~ /<?php print $subdir; ?>/admin/config/development/performance/redis {
access_log off;
rewrite ^ $scheme://$host/<?php print $subdir; ?>/admin/config/development/performance permanent;
return 301 $scheme://$host/<?php print $subdir; ?>/admin/config/development/performance;
}
<?php endif; ?>
......@@ -883,7 +883,7 @@ location ^~ /<?php print $subdir; ?> {
### Redirect to working homepage.
###
location = /<?php print $subdir; ?> {
rewrite ^ $scheme://$host/<?php print $subdir; ?>/? permanent;
return 301 $scheme://$host/<?php print $subdir; ?>/;
}
###
......@@ -1119,7 +1119,7 @@ location @drupal_<?php print $subdir_loc; ?> {
###
location @nobots_<?php print $subdir_loc; ?> {
if ($is_bot) {
rewrite ^ $scheme://$host$request_uri? permanent;
return 301 $scheme://$host$request_uri;
}
###
### Return 404 on special PHP URLs to avoid revealing version used,
......
......@@ -11,6 +11,6 @@ location ^~ /<?php print $subdir; ?>/ {
index index.html index.htm;
### Do not reveal Aegir front-end URL here.
<?php else: ?>
rewrite ^ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>? redirect;
return 302 <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>;
<?php endif; ?>
}
......@@ -16,7 +16,7 @@ if ($ssl_redirection || $this->redirection) {
print " server_name {$alias_url};\n";
}
print " access_log off;\n";
print " rewrite ^ \$scheme://{$this->redirection}\$request_uri? permanent;\n";
print " return 301 \$scheme://{$this->redirection}\$request_uri;\n";
print "}\n";
}
}
......@@ -78,11 +78,11 @@ server {
if ($this->redirection || $ssl_redirection) {
if ($ssl_redirection && !$this->redirection) {
// redirect aliases in non-ssl to the same alias on ssl.
print "\n rewrite ^ https://\$host\$request_uri? permanent;\n";
print "\n return 301 https://\$host\$request_uri;\n";
}
elseif ($ssl_redirection && $this->redirection) {
// redirect all aliases + main uri to the main https uri.
print "\n rewrite ^ https://{$this->redirection}\$request_uri? permanent;\n";
print "\n return 301 https://{$this->redirection}\$request_uri;\n";
}
elseif (!$ssl_redirection && $this->redirection) {
print " include " . $server->include_path . "/nginx_vhost_common.conf;\n";
......
......@@ -13,6 +13,6 @@ server {
index index.html index.htm;
### Do not reveal Aegir front-end URL here.
<?php else: ?>
rewrite ^ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>? redirect;
return 302 <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>;
<?php endif; ?>
}
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