| | |
| | | $nginx_directives = str_replace("\r", "\n", $nginx_directives); |
| | | $nginx_directive_lines = explode("\n", $nginx_directives); |
| | | if(is_array($nginx_directive_lines) && !empty($nginx_directive_lines)){ |
| | | $trans = array('{DOCROOT}' => $vhost_data['web_document_root_www'], '{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';'); |
| | | $trans = array( |
| | | '{DOCROOT}' => $vhost_data['web_document_root_www'], |
| | | '{DOCROOT_CLIENT}' => $vhost_data['web_document_root'], |
| | | '{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';' |
| | | ); |
| | | foreach($nginx_directive_lines as $nginx_directive_line){ |
| | | $final_nginx_directives[] = array('nginx_directive' => strtr($nginx_directive_line, $trans)); |
| | | } |
| | |
| | | $ssl_dir = $data['new']['document_root'].'/ssl'; |
| | | if(!isset($data['new']['ssl_domain']) OR empty($data['new']['ssl_domain'])) { $data['new']['ssl_domain'] = $data['new']['domain']; } |
| | | $domain = $data['new']['ssl_domain']; |
| | | if(!$domain) $domain = $data['new']['domain']; |
| | | $tpl->setVar('ssl_domain', $domain); |
| | | $key_file = $ssl_dir.'/'.$domain.'.key'; |
| | | $crt_file = $ssl_dir.'/'.$domain.'.crt'; |
| | |
| | | //* Generate Let's Encrypt SSL certificat |
| | | if($data['new']['ssl'] == 'y' && $data['new']['ssl_letsencrypt'] == 'y') { |
| | | //* be sure to have good domain |
| | | if(substr($domain, 0, 2) === '*.') { |
| | | // wildcard domain not yet supported by letsencrypt! |
| | | $app->log('Wildcard domains not yet supported by letsencrypt, so changing ' . $domain . ' to ' . substr($domain, 2), LOGLEVEL_WARN); |
| | | $domain = substr($domain, 2); |
| | | } |
| | | |
| | | $data['new']['ssl_domain'] = $domain; |
| | | $vhost_data['ssl_domain'] = $domain; |
| | | |
| | | $lddomain = (string) "$domain"; |
| | | if($data['new']['subdomain'] == "www" OR $data['new']['subdomain'] == "*") { |
| | | $lddomain .= (string) " --domains www." . $domain; |
| | |
| | | $app->system->chmod($webroot . "/.well-known/acme-challenge", "g+s"); |
| | | |
| | | if(file_exists("/root/.local/share/letsencrypt/bin/letsencrypt")) { |
| | | $this->_exec("/root/.local/share/letsencrypt/bin/letsencrypt auth --text --agree-tos --authenticator=webroot --server=https://acme-v01.api.letsencrypt.org/directory --rsa-key-size=4096 --webroot-path --email postmaster@$domain --domains $lddomain --webroot-path " . escapeshellarg($webroot)); |
| | | $this->_exec("/root/.local/share/letsencrypt/bin/letsencrypt auth --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@$domain --domains $lddomain --webroot-path " . escapeshellarg($webroot)); |
| | | } |
| | | }; |
| | | |