From 837f9e33a841b00fa9ed74e0dbf4bc56bbe095c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ba=CC=81lint=20Szekeres?= Date: Wed, 5 Jun 2019 17:03:33 +0200 Subject: [PATCH] ability to change nginx config directory fixes #93 --- public/assets/js/app.js | 1 + public/index.html | 37 +++++++++++++++++---------- public/templates/commands.html | 16 ++++++------ public/templates/conf/nginx.conf.html | 6 ++--- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/public/assets/js/app.js b/public/assets/js/app.js index 2d45849..2e93d34 100644 --- a/public/assets/js/app.js +++ b/public/assets/js/app.js @@ -101,6 +101,7 @@ user: 'www-data', pid: '/run/nginx.pid', client_max_body_size: 16, + directory_nginx: '/etc/nginx/', // COMMON - TOOLS file_structure: 'modularized', diff --git a/public/index.html b/public/index.html index 81dc011..be3bd3f 100644 --- a/public/index.html +++ b/public/index.html @@ -353,7 +353,7 @@ class="form-control form-control-sm" ng-model="data.sites[site].ssl_certificate" ng-class="{ 'input-changed': data.sites[site].ssl_certificate !== defaultData.sites[0].ssl_certificate }" - placeholder="{{ '/etc/nginx/ssl/' + getDomain() + '.crt' }}"> + placeholder="{{ data.directory_nginx + 'ssl/' + getDomain() + '.crt' }}">
@@ -365,7 +365,7 @@ class="form-control form-control-sm" ng-model="data.sites[site].ssl_certificate_key" ng-class="{ 'input-changed': data.sites[site].ssl_certificate_key !== defaultData.sites[0].ssl_certificate_key }" - placeholder="{{ '/etc/nginx/ssl/' + getDomain() + '.key' }}"> + placeholder="{{ data.directory_nginx + 'ssl/' + getDomain() + '.key' }}">
@@ -856,6 +856,17 @@
+
+ +
+ +
+
- /etc/nginx/nginx.conf + {{ data.directory_nginx }}nginx.conf @@ -1048,7 +1059,7 @@
- /etc/nginx/sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf + {{ data.directory_nginx }}sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf @@ -1057,7 +1068,7 @@
- /etc/nginx/nginxconfig.io/letsencrypt.conf + {{ data.directory_nginx }}nginxconfig.io/letsencrypt.conf @@ -1066,7 +1077,7 @@
- /etc/nginx/nginxconfig.io/security.conf + {{ data.directory_nginx }}nginxconfig.io/security.conf @@ -1075,7 +1086,7 @@
- /etc/nginx/nginxconfig.io/general.conf + {{ data.directory_nginx }}nginxconfig.io/general.conf @@ -1084,7 +1095,7 @@
- /etc/nginx/nginxconfig.io/php_fastcgi.conf + {{ data.directory_nginx }}nginxconfig.io/php_fastcgi.conf @@ -1093,7 +1104,7 @@
- /etc/nginx/nginxconfig.io/python_uwsgi.conf + {{ data.directory_nginx }}nginxconfig.io/python_uwsgi.conf @@ -1102,7 +1113,7 @@
- /etc/nginx/nginxconfig.io/proxy.conf + {{ data.directory_nginx }}nginxconfig.io/proxy.conf @@ -1111,7 +1122,7 @@
- /etc/nginx/nginxconfig.io/wordpress.conf + {{ data.directory_nginx }}nginxconfig.io/wordpress.conf @@ -1120,7 +1131,7 @@
- /etc/nginx/nginxconfig.io/drupal.conf + {{ data.directory_nginx }}nginxconfig.io/drupal.conf @@ -1129,7 +1140,7 @@
- /etc/nginx/nginxconfig.io/magento.conf + {{ data.directory_nginx }}nginxconfig.io/magento.conf diff --git a/public/templates/commands.html b/public/templates/commands.html index 289ce9b..31cf2ad 100644 --- a/public/templates/commands.html +++ b/public/templates/commands.html @@ -3,12 +3,12 @@ step: download -->. Download generated config: nginxconfig.io-{{ getDomains().join(',') }}.zip - Upload to server's /etc/nginx/ directory + Upload to server's {{ data.directory_nginx }} directory - OR - - Copy as Base64 string: Copy to clipboard (echo 'BASE64' | base64 --decode > /etc/nginx/nginxconfig.io-{{ getDomains().join(',') }}.zip) + Copy as Base64 string: Copy to clipboard (echo 'BASE64' | base64 --decode > {{ data.directory_nginx }}nginxconfig.io-{{ getDomains().join(',') }}.zip) Paste from clipboard and run the command . Go to NGINX directory (over SSH): - cd /etc/nginx + cd {{ data.directory_nginx }} . Backup current configuration: tar -czvf nginx_$(date +'%F_%H-%M-%S').tar.gz nginx.conf sites-available/ sites-enabled/ nginxconfig.io/ . Unzip the uploaded archive: @@ -23,7 +23,7 @@ -->. Generate Diffie-Hellman keys: - openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem {{ isSSLProfileLegacy() ? 1024 : 2048 }} + openssl dhparam -dsaparam -out {{ data.directory_nginx }}dhparam.pem {{ isSSLProfileLegacy() ? 1024 : 2048 }} . Comment out SSL related directives in configuration: sed -i -r 's/(listen .*443)/\1;#/g; s/(ssl_(certificate|certificate_key|trusted_certificate) )/#;#\1/g' /etc/nginx/nginx.conf /etc/nginx/sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf +--> {{ data.directory_nginx }}nginx.conf {{ data.directory_nginx }}sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf . Reload NGINX: sudo nginx -t && sudo systemctl reload nginx . Obtain certificate{{ getDomains().length > 1 ? 's' : '' }}:--force-renewal . Uncomment SSL related directives in configuration: sed -i -r 's/#?;#//g' /etc/nginx/nginx.conf /etc/nginx/sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf +--> {{ data.directory_nginx }}nginx.conf {{ data.directory_nginx }}sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf . Reload NGINX: sudo nginx -t && sudo systemctl reload nginx . Configure Certbot to reload NGINX after success renew: diff --git a/public/templates/conf/nginx.conf.html b/public/templates/conf/nginx.conf.html index b30e47a..13a44be 100644 --- a/public/templates/conf/nginx.conf.html +++ b/public/templates/conf/nginx.conf.html @@ -58,7 +58,7 @@ http { # Diffie-Hellman parameter for DHE ciphersuites - ssl_dhparam /etc/nginx/dhparam.pem; + ssl_dhparam {{ data.directory_nginx }}dhparam.pem; # {{ sslProfiles[ data.ssl_profile ].name }} configuration ssl_protocols {{ sslProfiles[ data.ssl_profile ].protocols }}; @@ -78,8 +78,8 @@ http {