diff --git a/platform/drupal/install_6.inc b/platform/drupal/install_6.inc index a809cb9..29bdfde 100644 --- a/platform/drupal/install_6.inc +++ b/platform/drupal/install_6.inc @@ -10,17 +10,24 @@ $GLOBALS['install_locale'] = drush_get_option('language'); $GLOBALS['client_email'] = drush_get_option('client_email'); // url generation code, should be factored out $proto = drush_get_option('ssl') ? 'https' : 'http'; -if (drush_get_option('site_port') == 80) { - if (drush_get_option('ssl')) { - $GLOBALS['base_url'] = $proto . '://' . $GLOBALS['url'] . ':80'; +if (is_array($options['site_port'])) { + foreach ($options['site_port'] as $port) { + $GLOBALS['base_url'] = $proto . '://' . $GLOBALS['url'] . ':' . $port; } } -elseif (drush_get_option('site_port') == 443) { - if (!drush_get_option('ssl')) { - $GLOBALS['base_url'] = $proto . '://' . $GLOBALS['url'] . ':443'; +else { + if (drush_get_option('site_port') == 80) { + if (drush_get_option('ssl')) { + $GLOBALS['base_url'] = $proto . '://' . $GLOBALS['url'] . ':80'; + } + } + elseif (drush_get_option('site_port') == 443) { + if (!drush_get_option('ssl')) { + $GLOBALS['base_url'] = $proto . '://' . $GLOBALS['url'] . ':443'; + } + } else { + $GLOBALS['base_url'] = $proto . '://' . $GLOBALS['url'] . ':' . $options['site_port']; } -} else { - $GLOBALS['base_url'] = $proto . '://' . $GLOBALS['url'] . ':' . drush_get_option('site_port'); } require_once 'includes/install.inc'; diff --git a/ssl/provision_ssl.drush.inc b/ssl/provision_ssl.drush.inc index 161b59a..faad171 100644 --- a/ssl/provision_ssl.drush.inc +++ b/ssl/provision_ssl.drush.inc @@ -19,14 +19,30 @@ * php_value session.cookie_secure 1 * SSLEngine On */ -function provision_ssl_provision_apache_vhost_config($url, $options) { +function provision_provision_apache_ssl_vhost_config($url, $options) { + $options = drush_get_merged_options(); if (!empty($options['ssl'])) { if ($options['ssl_redirect'] && provision_path('exists', drush_get_option('vhost_path') . '/' . $url . '_80', FALSE, NULL, t("The redirection port is not available, no redirection installed"))) { - $newoptions = $options; - $newoptions['site_port'] = 80; - _provision_apache_create_config($url . '_80', $newoptions, _provision_apache_redirect_template()); + if (is_array($options['site_port'])) { + foreach ($options['site_port'] as $port) { + if ($port !== '443') { + _provision_apache_create_config($url . '_' . $port, $newoptions, _provision_apache_redirect_template()); + } + } + } + else { + _provision_apache_create_config($url . '_' . $options['site_port'], $newoptions, _provision_apache_redirect_template()); + } + } + if (is_array($options['site_port'])) { + $ports = $options['site_port']; + foreach ($ports as $port) { + if ($port == 443) { + $result = array("php_value session.cookie_secure 1", "SSLEngine On"); + } + } + return $result; } - return array("php_value session.cookie_secure 1", "SSLEngine On"); } else { return NULL; } diff --git a/web_server/provision_apache.drush.inc b/web_server/provision_apache.drush.inc index d0cfb85..1c04a9c 100644 --- a/web_server/provision_apache.drush.inc +++ b/web_server/provision_apache.drush.inc @@ -94,13 +94,19 @@ function _provision_apache_delete_vhost_config($url) { } else { $options = drush_get_merged_options(); // backward compatibility with 0.3 - if (!$options['site_port'] || $options['site_port'] < 1 || $options['site_port'] > 65536) { - $options['site_port'] = 80; + if (is_array($options['site_port'])) { + foreach ($options['site_port'] as $port) { + $file = $url . '_' . $options['site_port']; + provision_path("unlink", drush_get_option('vhost_path') ."/" . $file, TRUE, dt("Removed apache virtual host configuration")); + drush_command_invoke_all('provision_apache_delete_vhost', $url, $options); + } + } + else { + $file = $url . '_' . $options['site_port']; + provision_path("unlink", drush_get_option('vhost_path') ."/" . $file, TRUE, dt("Removed apache virtual host configuration")); + drush_command_invoke_all('provision_apache_delete_vhost', $url, $options); } - $file = $url . '_' . $options['site_port']; - provision_path("unlink", drush_get_option('vhost_path') ."/" . $file, TRUE, dt("Removed apache virtual host configuration")); } - drush_command_invoke_all('provision_apache_delete_vhost', $url, $options); } /** @@ -127,10 +133,6 @@ function _provision_apache_delete_vhost_config($url) { */ function _provision_apache_create_vhost_config($url, $template = NULL) { $options = drush_get_merged_options(); - // backward compatibility with 0.3 - if (!$options['site_port'] || $options['site_port'] < 1 || $options['site_port'] > 66535) { - $options['site_port'] = 80; - } if (is_null($template)) { $template = _provision_apache_default_template(); } @@ -143,19 +145,38 @@ function _provision_apache_create_vhost_config($url, $template = NULL) { $options['extra_config'] = "# Extra configuration from modules:\n"; $options['extra_config'] .= join("\n", drush_command_invoke_all('provision_apache_vhost_config', $url, $options)); - /* one file per virtualhost name/port combination - * - * the rationale here is that we can have different sites on - * different ports that will be generated at different times, so we - * will not be able to generate a full config file for all ports in - * one pass - */ - $file = $url . '_' . $options['site_port']; - // backward compatibility with 0.3 - if (provision_path_exists(drush_get_option('vhost_path') .'/'. $url)) { - rename(drush_get_option('vhost_path') .'/'. $url, drush_get_option('vhost_path') .'/'. $file); + if (is_array($options['site_port'])) { + foreach ($options['site_port'] as $port) { + if ($port == 443) { + $options['extra_config'] .= join("\n", drush_command_invoke_all('provision_apache_ssl_vhost_config', $url, $options)); + } + /* one file per virtualhost name/port combination + * + * the rationale here is that we can have different sites on + * different ports that will be generated at different times, so we + * will not be able to generate a full config file for all ports in + * one pass + */ + $file = $url . '_' . $port; + // backward compatibility with 0.3 + if (provision_path_exists(drush_get_option('vhost_path') .'/'. $url)) { + rename(drush_get_option('vhost_path') .'/'. $url, drush_get_option('vhost_path') .'/'. $file); + } + $options['site_port'] = $port; + _provision_apache_create_config($file, $options, $template); + } + } + else { + $file = $url . '_' . $options['site_port']; + if ($options['site_port'] == 443) { + $options['extra_config'] .= join("\n", drush_command_invoke_all('provision_apache_ssl_vhost_config', $url, $options)); + } + // backward compatibility with 0.3 + if (provision_path_exists(drush_get_option('vhost_path') .'/'. $url)) { + rename(drush_get_option('vhost_path') .'/'. $url, drush_get_option('vhost_path') .'/'. $file); + } + return _provision_apache_create_config($file, $options, $template); } - return _provision_apache_create_config($file, $options, $template); } /** diff --git a/web_server/provision_apache_vhost_redirect.tpl.php b/web_server/provision_apache_vhost_redirect.tpl.php index 2bf9d8b..dc8aeb9 100644 --- a/web_server/provision_apache_vhost_redirect.tpl.php +++ b/web_server/provision_apache_vhost_redirect.tpl.php @@ -1,16 +1,24 @@ > - - ServerAdmin - + + ServerAdmin + - ServerName - - ServerAlias - + + ServerAlias + + ServerAlias + + + RedirectMatch permanent ^(.*) https://$1 + + RedirectMatch permanent ^(.*) http://$1 + + RedirectMatch permanent ^(.*) http://:$1 + - RedirectMatch permanent ^(.*) http://$1