Skip to content

Commit f5bd972

Browse files
author
Marius Burkard
committed
Merge branch '6017-ssl-for-nginx-apps-vhost' into 'develop'
Resolve "SSL for nginx apps vhost" Closes #6017 and #6007 See merge request ispconfig/ispconfig3!1422
2 parents d0d5415 + 08bd30a commit f5bd972

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

install/lib/installer_base.lib.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,7 +2553,7 @@ public function configure_apps_vhost() {
25532553
$tpl->setVar('apps_vhost_dir',$conf['web']['website_basedir'].'/apps');
25542554
$tpl->setVar('apps_vhost_basedir',$conf['web']['website_basedir']);
25552555
$tpl->setVar('apps_vhost_servername',$apps_vhost_servername);
2556-
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
2556+
if(is_file($conf['ispconfig_install_dir'].'/interface/ssl/ispserver.crt') && is_file($conf['ispconfig_install_dir'].'/interface/ssl/ispserver.key')) {
25572557
$tpl->setVar('ssl_comment','');
25582558
} else {
25592559
$tpl->setVar('ssl_comment','#');
@@ -2636,6 +2636,15 @@ public function configure_apps_vhost() {
26362636
// Dont just copy over the virtualhost template but add some custom settings
26372637
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/nginx_apps.vhost.master', 'tpl/nginx_apps.vhost.master');
26382638

2639+
// Enable SSL if a cert is in place.
2640+
if(is_file($conf['ispconfig_install_dir'].'/interface/ssl/ispserver.crt') && is_file($conf['ispconfig_install_dir'].'/interface/ssl/ispserver.key')) {
2641+
$content = str_replace('{ssl_on}', 'ssl', $content);
2642+
$content = str_replace('{ssl_comment}', '', $content);
2643+
} else {
2644+
$content = str_replace('{ssl_on}', '', $content);
2645+
$content = str_replace('{ssl_comment}', '#', $content);
2646+
}
2647+
26392648
if($conf['web']['apps_vhost_ip'] == '_default_'){
26402649
$apps_vhost_ip = '';
26412650
} else {
@@ -2678,10 +2687,6 @@ public function configure_apps_vhost() {
26782687
$content = str_replace('{use_tcp}', $use_tcp, $content);
26792688
$content = str_replace('{use_socket}', $use_socket, $content);
26802689

2681-
// SSL in apps vhost is off by default. Might change later.
2682-
$content = str_replace('{ssl_on}', '', $content);
2683-
$content = str_replace('{ssl_comment}', '#', $content);
2684-
26852690
// Fix socket path on PHP 7 systems
26862691
if(file_exists('/var/run/php/php7.0-fpm.sock')) $content = str_replace('/var/run/php5-fpm.sock', '/var/run/php/php7.0-fpm.sock', $content);
26872692
if(file_exists('/var/run/php/php7.1-fpm.sock')) $content = str_replace('/var/run/php5-fpm.sock', '/var/run/php/php7.1-fpm.sock', $content);

install/tpl/nginx_apps.vhost.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ server {
77
{ssl_comment}ssl_certificate_key /usr/local/ispconfig/interface/ssl/ispserver.key;
88

99
# redirect to https if accessed with http
10-
{ssl_comment}error_page 497 https://$host:{vhost_port}$request_uri;
10+
{ssl_comment}error_page 497 https://$host:{apps_vhost_port}$request_uri;
1111

1212
server_name {apps_vhost_servername};
1313

server/conf/nginx_apps.vhost.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ server {
77
{ssl_comment}ssl_certificate_key /usr/local/ispconfig/interface/ssl/ispserver.key;
88

99
# redirect to https if accessed with http
10-
{ssl_comment}error_page 497 https://$host:{vhost_port}$request_uri;
10+
{ssl_comment}error_page 497 https://$host:{apps_vhost_port}$request_uri;
1111

1212
server_name {apps_vhost_servername};
1313

server/plugins-available/apps_vhost_plugin.inc.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,14 @@ function update($event_name, $data) {
206206
$use_socket = '#';
207207
}
208208

209-
/* Check if SSL should be enabled: */
210-
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
209+
/* Check if SSL should be enabled: */
210+
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
211211
$content = str_replace('{ssl_comment}', '', $content);
212212
$content = str_replace('{ssl_on}', 'ssl', $content);
213-
$content = str_replace('{vhost_port}', $web_config['apps_vhost_port'], $content);
214-
} else {
213+
} else {
215214
$content = str_replace('{ssl_comment}', '#', $content);
216215
$content = preg_replace('/(\s)\{ssl_on\}/', '', $content);
217-
$content = str_replace('{vhost_port}', $web_config['apps_vhost_port'], $content);
218-
}
216+
}
219217

220218
$content = str_replace('{use_tcp}', $use_tcp, $content);
221219
$content = str_replace('{use_socket}', $use_socket, $content);

0 commit comments

Comments
 (0)