Skip to content

Commit 70c2415

Browse files
committed
Turn off force SSL during LE
1 parent 045e9a9 commit 70c2415

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

vscode.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public function build_le_cert( $user ) {
4949
rename( $ssl_conf, $ssl_sav );
5050
rename( $conf, $sav );
5151

52+
// Turn off force SSL
53+
$force_ssl_conf = "/home/$user/conf/web/vscode-$user.$domain/nginx.forcessl.conf";
54+
$force_ssl_sav = "/home/$user/conf/web/vscode-$user.$domain/nginx.forcessl.sav";
55+
rename( $force_ssl_conf, $force_ssl_sav );
56+
5257
// Create empty nginx.ssl.conf file
5358
touch( $ssl_conf );
5459

@@ -69,9 +74,10 @@ public function build_le_cert( $user ) {
6974
$content
7075
) );
7176

72-
// Restart nginx to serve up the le-webroot folder
73-
shell_exec( 'service nginx restart' );
74-
77+
// Restart nginx to serve le-webroot folder
78+
$cmd = '/usr/sbin/service nginx restart 2>&1';
79+
$hcpp->log( 'Restart nginx to serve le-webroot: ' . shell_exec($cmd) );
80+
7581
// Use certbot to generate the LE certificate
7682
$cmd = "certbot certonly --webroot -w /home/$user/conf/web/vscode-$user.$domain/le-webroot -d vscode-$user.$domain --email $email --agree-tos --non-interactive";
7783
$cmd = $hcpp->do_action( 'vscode_build_le_cert', $cmd );
@@ -81,6 +87,7 @@ public function build_le_cert( $user ) {
8187
} else {
8288

8389
// Link to the LE certificate and key
90+
$hcpp->log("Successfully generated LE certificate: " . implode("\n", $output)); sudo systemctl start nginx
8491
$cert_file = "/etc/letsencrypt/live/vscode-$user.$domain/fullchain.pem";
8592
$key_file = "/etc/letsencrypt/live/vscode-$user.$domain/privkey.pem";
8693
$cert_link = "/home/$user/conf/web/vscode-$user.$domain/ssl/vscode-$user.$domain.pem";
@@ -89,11 +96,17 @@ public function build_le_cert( $user ) {
8996
@symlink( $key_file, $key_link );
9097
}
9198

92-
// Restore the original nginx.conf and nginx.ssl.conf files
99+
// Restore the original nginx.conf and nginx.ssl.conf and force_ssl files
93100
if ( file_exists( $ssl_conf ) ) unlink( $ssl_conf );
94101
rename( $ssl_sav, $ssl_conf );
95102
if ( file_exists( $conf ) ) unlink( $conf );
96103
rename( $sav, $conf );
104+
if ( file_exists( $force_ssl_conf ) ) unlink( $force_ssl_conf );
105+
rename( $force_ssl_sav, $force_ssl_conf );
106+
107+
// Restart nginx to serve vscode- folder
108+
$cmd = '/usr/sbin/service nginx restart 2>&1';
109+
$hcpp->log( 'Restart nginx to serve -vscode: ' . shell_exec($cmd) );
97110
}
98111

99112
/**

0 commit comments

Comments
 (0)