Skip to content

Commit

Permalink
ability to change nginx config directory
Browse files Browse the repository at this point in the history
fixes #93
  • Loading branch information
0xb4lint committed Jun 5, 2019
1 parent 488a897 commit 837f9e3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
1 change: 1 addition & 0 deletions public/assets/js/app.js
Expand Up @@ -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',
Expand Down
37 changes: 24 additions & 13 deletions public/index.html
Expand Up @@ -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' }}">
</div>
</div>
<div class="form-group row" ng-if="isHTTPS() && isCertCustom()" ng-cloak>
Expand All @@ -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' }}">
</div>
</div>
</div>
Expand Down Expand Up @@ -856,6 +856,17 @@
</div>
</div>
<div class="tab-pane tab-nginx" ng-class="{ 'active': tab_common === 'nginx' }">
<div class="form-group row">
<label class="col-sm-3 col-form-label col-form-label-sm">
NGINX config directory
</label>
<div class="col-sm-9">
<input type="text"
class="form-control form-control-sm"
ng-model="data.directory_nginx"
ng-class="{ 'input-changed': data.directory_nginx !== defaultData.directory_nginx }">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label col-form-label-sm">
<code tooltips tooltip-template="Defines the number of worker processes. ">worker_processes</code>
Expand Down Expand Up @@ -1039,7 +1050,7 @@
<div id="base64-zip-line">{{ base64 }}</div>
</div>
<section class="file grid-item" ng-class="isModularized() || isWordPress() ? 'col-xl-6' : 'col-xl-12'" ng-cloak>
<strong>/etc/nginx/nginx.conf</strong>
<strong>{{ data.directory_nginx }}nginx.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-nginx" ngclipboard-success="clipboardSuccess('nginx.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1048,7 +1059,7 @@
</div><div id="file-nginx" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="isModularized()" ng-repeat="(_site, _domain) in getDomains() track by $index" ng-cloak>
<strong>/etc/nginx/sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf</strong>
<strong>{{ data.directory_nginx }}sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-domain-{{ $index }}" ngclipboard-success="clipboardSuccess('example.com')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1057,7 +1068,7 @@
</div><div id="file-domain-{{ $index }}" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="isModularized() && hasCertLetsEncrypt()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/letsencrypt.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/letsencrypt.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-letsencrypt" ngclipboard-success="clipboardSuccess('letsencrypt.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1066,7 +1077,7 @@
</div><div id="file-letsencrypt" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/security.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/security.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-security" ngclipboard-success="clipboardSuccess('security.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1075,7 +1086,7 @@
</div><div id="file-security" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/general.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/general.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-general" ngclipboard-success="clipboardSuccess('general.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1084,7 +1095,7 @@
</div><div id="file-general" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="hasPHP() && (isModularized() || hasWordPress())" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/php_fastcgi.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/php_fastcgi.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-php_fastcgi" ngclipboard-success="clipboardSuccess('php_fastcgi.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1093,7 +1104,7 @@
</div><div id="file-php_fastcgi" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="hasPython() && isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/python_uwsgi.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/python_uwsgi.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-python_uwsgi" ngclipboard-success="clipboardSuccess('python_uwsgi.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1102,7 +1113,7 @@
</div><div id="file-python_uwsgi" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="hasProxy() && isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/proxy.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/proxy.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-proxy" ngclipboard-success="clipboardSuccess('proxy.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1111,7 +1122,7 @@
</div><div id="file-proxy" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="hasWordPress() && isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/wordpress.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/wordpress.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-wordpress" ngclipboard-success="clipboardSuccess('wordpress.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1120,7 +1131,7 @@
</div><div id="file-wordpress" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="hasDrupal() && isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/drupal.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/drupal.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-drupal" ngclipboard-success="clipboardSuccess('drupal.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand All @@ -1129,7 +1140,7 @@
</div><div id="file-drupal" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="hasMagento() && isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/magento.conf</strong>
<strong>{{ data.directory_nginx }}nginxconfig.io/magento.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-magento" ngclipboard-success="clipboardSuccess('magento.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
Expand Down
16 changes: 8 additions & 8 deletions public/templates/commands.html
Expand Up @@ -3,12 +3,12 @@
step: download
--><span class="hljs-comment"><span class="counter">.</span> <strong>Download</strong> generated config:</span> <strong><a href="#" ng-click="downloadZip()">nginxconfig.io-{{ getDomains().join(',') }}.zip</a></strong>
<span class="hljs-comment"><strong>Upload</strong> to server's</span> <strong>/etc/nginx/</strong> <span class="hljs-comment">directory</span>
<span class="hljs-comment"><strong>Upload</strong> to server's</span> <strong>{{ data.directory_nginx }}</strong> <span class="hljs-comment">directory</span>
<span class="hljs-comment">- OR -</span>
<span class="hljs-comment"><strong>Copy</strong> as Base64 string:</span> <strong><a href="#" ng-mouseenter="prepareBase64()" ng-click="copyAsBase64()" ngclipboard data-clipboard-target="#base64-zip-line" ngclipboard-success="clipboardSuccess('base64-zip-line')">Copy to clipboard</a></strong> <span class="hljs-comment small">(echo 'BASE64' | base64 --decode > /etc/nginx/nginxconfig.io-{{ getDomains().join(',') }}.zip)</span>
<span class="hljs-comment"><strong>Copy</strong> as Base64 string:</span> <strong><a href="#" ng-mouseenter="prepareBase64()" ng-click="copyAsBase64()" ngclipboard data-clipboard-target="#base64-zip-line" ngclipboard-success="clipboardSuccess('base64-zip-line')">Copy to clipboard</a></strong> <span class="hljs-comment small">(echo 'BASE64' | base64 --decode > {{ data.directory_nginx }}nginxconfig.io-{{ getDomains().join(',') }}.zip)</span>
<span class="hljs-comment"><strong>Paste</strong> from clipboard and run the command</span>
<span class="hljs-comment"><span class="counter">.</span> Go to NGINX directory (over SSH):</span>
<span class="hljs-section">cd</span> /etc/nginx
<span class="hljs-section">cd</span> {{ data.directory_nginx }}
<span class="hljs-comment"><span class="counter">.</span> Backup current configuration:</span>
<span class="hljs-section">tar</span> <span class="hljs-attribute">-czvf</span> nginx_$(date +'%F_%H-%M-%S').tar.gz nginx.conf sites-available/ sites-enabled/ nginxconfig.io/
<span class="hljs-comment"><span class="counter">.</span> Unzip the uploaded archive:</span>
Expand All @@ -23,7 +23,7 @@
--><!--
✔ SSL DH required --><span ng-if="isSSLDHRequired()"><span class="hljs-comment"><span class="counter">.</span> Generate Diffie-Hellman keys:</span>
<span class="hljs-section">openssl</span> <span class="hljs-attribute">dhparam -dsaparam</span> <span class="hljs-attribute">-out</span> /etc/nginx/dhparam.pem <span class="hljs-number">{{ isSSLProfileLegacy() ? 1024 : 2048 }}</span>
<span class="hljs-section">openssl</span> <span class="hljs-attribute">dhparam -dsaparam</span> <span class="hljs-attribute">-out</span> {{ data.directory_nginx }}dhparam.pem <span class="hljs-number">{{ isSSLProfileLegacy() ? 1024 : 2048 }}</span>
</span><!--
✔ Let's Encrypt
Expand All @@ -39,8 +39,8 @@
--><span class="hljs-comment"><span class="counter">.</span> Comment out SSL related directives in configuration:</span>
<span class="hljs-section">sed</span> <span class="hljs-attribute">-i -r</span> 's/(listen .*443)/\1;#/g; s/(ssl_(certificate|certificate_key|trusted_certificate) )/#;#\1/g'<span ng-if="isUnified()"><!--
--> /etc/nginx/nginx.conf</span><span ng-if="isModularized()"><span ng-repeat="(_site, _domain) in getDomains() track by $index" ng-if="isCertLetsEncrypt(_site)"><!--
--> /etc/nginx/sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf</span></span>
--> {{ data.directory_nginx }}nginx.conf</span><span ng-if="isModularized()"><span ng-repeat="(_site, _domain) in getDomains() track by $index" ng-if="isCertLetsEncrypt(_site)"><!--
--> {{ data.directory_nginx }}sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf</span></span>
<span class="hljs-comment"><span class="counter">.</span> Reload <strong>NGINX</strong>:</span>
<strong>sudo</strong> <span class="hljs-section">nginx</span> <span class="hljs-attribute">-t</span> && <strong>sudo</strong> <span class="hljs-section">systemctl</span> <span class="hljs-attribute">reload</span> nginx
<span class="hljs-comment"><span class="counter">.</span> Obtain certificate{{ getDomains().length > 1 ? 's' : '' }}:</span><!--
Expand All @@ -58,8 +58,8 @@
--><span class="hljs-attribute">--force-renewal</span></span>
<span class="hljs-comment"><span class="counter">.</span> Uncomment SSL related directives in configuration:</span>
<span class="hljs-section">sed</span> <span class="hljs-attribute">-i -r</span> 's/#?;#//g'<span ng-if="isUnified()"><!--
--> /etc/nginx/nginx.conf</span><span ng-if="isModularized()"><span ng-repeat="(_site, _domain) in getDomains() track by $index" ng-if="isCertLetsEncrypt(_site)"><!--
--> /etc/nginx/sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf</span></span>
--> {{ data.directory_nginx }}nginx.conf</span><span ng-if="isModularized()"><span ng-repeat="(_site, _domain) in getDomains() track by $index" ng-if="isCertLetsEncrypt(_site)"><!--
--> {{ data.directory_nginx }}sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf</span></span>
<span class="hljs-comment"><span class="counter">.</span> Reload <strong>NGINX</strong>:</span>
<strong>sudo</strong> <span class="hljs-section">nginx</span> <span class="hljs-attribute">-t</span> && <strong>sudo</strong> <span class="hljs-section">systemctl</span> <span class="hljs-attribute">reload</span> nginx
<span class="hljs-comment"><span class="counter">.</span> Configure <strong>Certbot</strong> to reload <strong>NGINX</strong> after success renew:</span>
Expand Down
6 changes: 3 additions & 3 deletions public/templates/conf/nginx.conf.html
Expand Up @@ -58,7 +58,7 @@
✔ SSL DH required --><span ng-if="isSSLDHRequired()">

# Diffie-Hellman parameter for DHE ciphersuites
ssl_dhparam /etc/nginx/dhparam.pem;</span>
ssl_dhparam {{ data.directory_nginx }}dhparam.pem;</span>

# {{ sslProfiles[ data.ssl_profile ].name }} configuration
ssl_protocols {{ sslProfiles[ data.ssl_profile ].protocols }};
Expand All @@ -78,8 +78,8 @@
resolver_timeout 2s;</span></span>

# load configs
include /etc/nginx/conf.d/*.conf;<span ng-if="isModularized()">
include /etc/nginx/sites-enabled/*;</span><span ng-if="isUnified()" ng-repeat="(_site, _domain) in getDomains() track by $index">
include {{ data.directory_nginx }}conf.d/*.conf;<span ng-if="isModularized()">
include {{ data.directory_nginx }}sites-enabled/*;</span><span ng-if="isUnified()" ng-repeat="(_site, _domain) in getDomains() track by $index">

# {{ isWWW(_site) ? 'www.' : '' }}{{ _domain }}
<ng-include ng-include-tabs="1" src="'templates/conf/sites-available/example.com.conf.html?v=COMMIT_HASH'" sonload="refreshHighlighting()"></ng-include></span>
Expand Down

0 comments on commit 837f9e3

Please sign in to comment.