mirror of
https://github.com/digitalocean/nginxconfig.io.git
synced 2025-08-09 14:07:27 +08:00
refactored command with steps
This commit is contained in:
@@ -1,65 +1,67 @@
|
||||
<!-- ✔ symlink --><span ng-if="isSymlink()"><!--
|
||||
<span class="step" ng-if="activeStep === 'download'"><!--
|
||||
|
||||
--><span class="hljs-comment"># <strong>Virtual host</strong>: create symbolic link{{ getDomains().length > 1 ? 's' : '' }}</span>
|
||||
<span class="hljs-section">ln</span> <span class="hljs-attribute">-s</span> <span ng-repeat="(_site, _domain) in getDomains() track by $index">/etc/nginx/sites-available/{{ _domain }}.conf </span>/etc/nginx/sites-enabled</span><!--
|
||||
step: download
|
||||
|
||||
--><span class="hljs-comment"><span class="counter">.</span> Download generated config:</span> <strong><a href="#" ng-click="downloadZip()">nginxconfig.io-{{ getDomains().join(',') }}.zip</a></strong>
|
||||
<span class="hljs-comment"><span class="counter">.</span> Upload to server's <strong>/etc/nginx/</strong> directory</span>
|
||||
<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>
|
||||
<span class="hljs-section">cd</span> /etc/nginx
|
||||
<span class="hljs-section">unzip</span> <span class="hljs-attribute">-o</span> nginxconfig.io-{{ getDomains().join(',') }}.zip <span class="hljs-comment">(you probably need to install <strong>unzip</strong>:</span> <span class="hljs-section"></span><strong>sudo</strong> <span class="hljs-section">apt-get</span> <span class="hljs-attribute">install</span> unzip<span class="hljs-comment">)</span></span><!--
|
||||
|
||||
|
||||
✔ symlink || ✔ HTTPS --><span ng-if="isSymlink() && (isSSLDHRequired() || hasCertLetsEncrypt())">
|
||||
|
||||
--><span class="step" ng-if="activeStep === 'ssl'"><!--
|
||||
|
||||
step: ssl
|
||||
|
||||
--><!--
|
||||
|
||||
✔ 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><!--
|
||||
|
||||
|
||||
✔ SSL DH required --><span ng-if="isSSLDHRequired()"><!--
|
||||
|
||||
--><span class="hljs-comment"># <strong>HTTPS</strong>: create Diffie-Hellman keys</span>
|
||||
<span class="hljs-section">openssl dhparam</span> <span class="hljs-attribute">-dsaparam</span> <span class="hljs-attribute">-out</span> /etc/nginx/dhparam.pem <span class="hljs-number">{{ isSSLProfileLegacy() ? 1024 : 2048 }}</span><!--
|
||||
|
||||
--><span ng-if="hasCertLetsEncrypt()">
|
||||
|
||||
</span></span><!--
|
||||
|
||||
|
||||
✔ Let's Encrypt --><span ng-if="hasCertLetsEncrypt()"><!--
|
||||
--><span class="hljs-comment"># <strong>HTTPS - certbot</strong> (before first run): create ACME-challenge common directory</span>
|
||||
<span class="hljs-section">mkdir</span> <span class="hljs-attribute">-p</span> /var/www/_letsencrypt && <span class="hljs-section">chown</span> <span class="hljs-attribute">{{ data.user }}</span> /var/www/_letsencrypt
|
||||
<!--
|
||||
✔ Let's Encrypt
|
||||
--><span ng-if="hasCertLetsEncrypt()"><span class="hljs-comment"><span class="counter">.</span> Create a common ACME-challenge directory (for Let's Encrypt):</span>
|
||||
<span class="hljs-section">mkdir</span> <span class="hljs-attribute">-p</span> /var/www/_letsencrypt
|
||||
<span class="hljs-section">chown</span> <span class="hljs-attribute">{{ data.user }}</span> /var/www/_letsencrypt</span></span><!--
|
||||
|
||||
|
||||
|
||||
-->
|
||||
<span class="hljs-comment"># <strong>HTTPS - certbot</strong> (before first run): disable SSL directives</span>
|
||||
<span class="hljs-section">sed</span> <!--
|
||||
--><span class="hljs-attribute">-i</span> <!--
|
||||
--><span class="hljs-attribute">-r</span> <!--
|
||||
-->'s/(listen .*443)/\1;#/g; s/(ssl_(certificate|certificate_key|trusted_certificate) )/#;#\1/g'<span ng-if="isUnified()"><!--
|
||||
--><span class="step" ng-if="activeStep === 'certbot'"><!--
|
||||
|
||||
step: certbot
|
||||
|
||||
--><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>
|
||||
<!--
|
||||
|
||||
|
||||
|
||||
-->
|
||||
<span class="hljs-comment"># <strong>HTTPS - certbot</strong>: obtain certificates</span><!--
|
||||
<span class="hljs-comment"><span class="counter">.</span> Reload NGINX:</span>
|
||||
<strong>sudo</strong> <span class="hljs-section">systemctl</span> <span class="hljs-attribute">reload</span> nginx.service
|
||||
<span class="hljs-comment"><span class="counter">.</span> Obtain certificate{{ getDomains().length > 1 ? 's' : '' }}:</span><!--
|
||||
--><span ng-repeat="(_site, _domain) in getDomains() track by $index" ng-if="isCertLetsEncrypt(_site)">
|
||||
<span class="hljs-section">certbot certonly</span> <!--
|
||||
<span class="hljs-section">certbot</span> <!--
|
||||
--><span class="hljs-attribute">certonly</span> <!--
|
||||
--><span class="hljs-attribute">--webroot</span> <!--
|
||||
--><span ng-if="isNonWWW(_site) || isRedirect(_site)"><span class="hljs-attribute" tooltips tooltip-template="--domain">-d</span> {{ _domain }} </span><!--
|
||||
--><span ng-if="isWWW(_site) || isRedirect(_site)"><span class="hljs-attribute" tooltips tooltip-template="--domain">-d</span> www.{{ _domain }} </span><!--
|
||||
--><span ng-if="isCDN(_site)"><span class="hljs-attribute" tooltips tooltip-template="--domain">-d</span> cdn.{{ _domain }} </span><!--
|
||||
--><span ng-if="isNonWWW(_site) || isRedirect(_site)"><span class="hljs-attribute" tooltips tooltip-template="--domain" tooltip-side="top">-d</span> {{ _domain }} </span><!--
|
||||
--><span ng-if="isWWW(_site) || isRedirect(_site)"><span class="hljs-attribute" tooltips tooltip-template="--domain" tooltip-side="top">-d</span> www.{{ _domain }} </span><!--
|
||||
--><span ng-if="isCDN(_site)"><span class="hljs-attribute" tooltips tooltip-template="--domain" tooltip-side="top">-d</span> cdn.{{ _domain }} </span><!--
|
||||
--><span class="hljs-attribute">--email</span> {{ data.sites[_site].email ? data.sites[_site].email : 'info@' + _domain }} <!--
|
||||
--><span class="hljs-attribute" tooltips tooltip-template="--webroot-path">-w</span> /var/www/_letsencrypt <!--
|
||||
--><span class="hljs-attribute" tooltips tooltip-template="--non-interactive">-n</span> <!--
|
||||
--><span class="hljs-attribute" tooltips tooltip-template="--webroot-path" tooltip-side="top">-w</span> /var/www/_letsencrypt <!--
|
||||
--><span class="hljs-attribute" tooltips tooltip-template="--non-interactive" tooltip-side="top">-n</span> <!--
|
||||
--><span class="hljs-attribute">--agree-tos</span> <!--
|
||||
--><span class="hljs-attribute">--force-renewal</span></span>
|
||||
<!--
|
||||
|
||||
|
||||
|
||||
-->
|
||||
<span class="hljs-comment"># <strong>HTTPS - certbot</strong> (after first run): enable SSL directives</span>
|
||||
<span class="hljs-section">sed</span> <!--
|
||||
--><span class="hljs-attribute">-i</span> <!--
|
||||
--><span class="hljs-attribute">-r</span> <!--
|
||||
-->'s/#?;#//g'<span ng-if="isUnified()"><!--
|
||||
<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></span>
|
||||
--> /etc/nginx/sites-{{ isSymlink() ? 'available' : 'enabled' }}/{{ _domain }}.conf</span></span></span><!--
|
||||
|
||||
|
||||
|
||||
--><span class="step" ng-if="activeStep === 'live'"><!--
|
||||
|
||||
step: live
|
||||
|
||||
--><span class="hljs-comment"><span class="counter">.</span> Reload NGINX:</span>
|
||||
<strong>sudo</strong> <span class="hljs-section">systemctl</span> <span class="hljs-attribute">reload</span> nginx.service</span>
|
||||
|
Reference in New Issue
Block a user