Commit 0dd026e8 authored by memtkmcc's avatar memtkmcc

Issue #3149961: Nginx templates update

parent e3f34080
......@@ -3,6 +3,11 @@
<?php if ($this->ssl_enabled && $this->ssl_key) : ?>
<?php
$script_user = drush_get_option('script_user');
if (!$script_user && $server->script_user) {
$script_user = $server->script_user;
}
$satellite_mode = drush_get_option('satellite_mode');
if (!$satellite_mode && $server->satellite_mode) {
$satellite_mode = $server->satellite_mode;
......
<?php $this->root = provision_auto_fix_platform_root($this->root); ?>
<?php
$script_user = drush_get_option('script_user');
if (!$script_user && $server->script_user) {
$script_user = $server->script_user;
}
if ($this->redirection) {
$aegir_root = d('@server_master')->aegir_root;
$satellite_mode = d('@server_master')->satellite_mode;
// Redirect all aliases to the main http url using separate vhosts blocks to avoid if{} in Nginx.
foreach ($this->aliases as $alias_url) {
print "# alias redirection virtual host\n";
print "server {\n";
print " listen *:{$http_port};\n";
// 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";
}
print " access_log off;\n";
if ($satellite_mode == 'boa') {
if (!preg_match("/\.(?:nodns)\./", $alias_url)) {
print "\n";
print " ###\n";
print " ### Allow access to letsencrypt.org ACME challenges directory.\n";
print " ###\n";
print " location ^~ /.well-known/acme-challenge {\n";
print " alias {$aegir_root}/tools/le/.acme-challenges;\n";
print " try_files \$uri 404;\n";
print " }\n";
print "# alias redirection virtual host\n";
print "server {\n";
print " listen *:{$http_port};\n";
print " #listen [::]:{$http_port};\n";
// 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";
}
print " access_log off;\n";
if ($satellite_mode == 'boa') {
print "\n";
print " ###\n";
print " ### Allow access to letsencrypt.org ACME challenges directory.\n";
print " ###\n";
print " location ^~ /.well-known/acme-challenge {\n";
print " alias {$aegir_root}/tools/le/.acme-challenges;\n";
print " try_files \$uri 404;\n";
print " }\n";
print "\n";
}
print " return 301 \$scheme://{$this->redirection}\$request_uri;\n";
print "}\n";
}
}
}
if ($this->redirection || !$this->redirection) {
$aegir_root = d('@server_master')->aegir_root;
$satellite_mode = d('@server_master')->satellite_mode;
foreach ($this->aliases as $alias_url) {
if (preg_match("/\.(?:nodns)\./", $alias_url)) {
print "\n";
print "# nodns alias exception virtual host\n";
print "server {\n";
print " listen *:{$http_port};\n";
print " #listen [::]:{$http_port};\n";
print " include fastcgi_params;\n";
print " fastcgi_param HTTP_PROXY \"\";\n";
print " fastcgi_param MAIN_SITE_NAME {$this->uri};\n";
print " set \$main_site_name {$this->uri};\n";
print " fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n";
if (!$db_type || !$db_name || !$db_user || !$db_passwd || !$db_host) {
$db_type = 'mysqli';
$db_name = 'none';
$db_user = 'none';
$db_passwd = 'none';
$db_host = 'localhost';
}
$db_type = urlencode($db_type);
$db_name = urlencode($db_name);
$db_user = urlencode($db_user);
$db_passwd = urlencode($db_passwd);
$db_host = urlencode($db_host);
print " fastcgi_param db_type {$db_type};\n";
print " fastcgi_param db_name {$db_name};\n";
print " fastcgi_param db_user {$db_user};\n";
print " fastcgi_param db_passwd {$db_passwd};\n";
print " fastcgi_param db_host {$db_host};\n";
if (!$db_port) {
$ctrlf = '/data/conf/' . $script_user . '_use_proxysql.txt';
if (provision_file()->exists($ctrlf)->status()) {
$db_port = '6033';
}
else {
$db_port = $this->server->db_port ? $this->server->db_port : '3306';
}
}
$db_port = urlencode($db_port);
print " fastcgi_param db_port {$db_port};\n";
$alias_url = str_replace('/', '.', $alias_url);
print " server_name {$alias_url};\n";
print " root {$this->root};\n";
print " include " . $server->include_path . "/nginx_vhost_common.conf;\n";
print "}\n";
}
print " return 301 \$scheme://{$this->redirection}\$request_uri;\n";
print "}\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