summaryrefslogtreecommitdiff
path: root/blog/dst/a/website_with_nginx.html
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2021-03-20 02:46:53 -0700
committerDavid Luevano Alvarado <david@luevano.xyz>2021-03-20 02:46:53 -0700
commite331c60377e62f158bdcdedfc7a0664104cd8e03 (patch)
tree9cdaa6fbafc6b4718108c0b6ca6fd37b6b46b4b2 /blog/dst/a/website_with_nginx.html
parent32d1f58c22c2de68c1ec7d8696777990c89c6e77 (diff)
Publish mail entry and reflect sbg fix
Diffstat (limited to 'blog/dst/a/website_with_nginx.html')
-rw-r--r--blog/dst/a/website_with_nginx.html34
1 files changed, 17 insertions, 17 deletions
diff --git a/blog/dst/a/website_with_nginx.html b/blog/dst/a/website_with_nginx.html
index 45366e4..69b371b 100644
--- a/blog/dst/a/website_with_nginx.html
+++ b/blog/dst/a/website_with_nginx.html
@@ -65,7 +65,7 @@
<p>These are general notes on how to setup a Nginx web server plus Certbot for SSL certificates, initially learned from <a href="https://www.youtube.com/watch?v=OWAqilIVNgE">Luke's video</a> and after some use and research I added more stuff to the mix. And, actually at the time of writing this entry, I'm configuring the web server again on a new VPS instance, so this is going to be fresh.</p>
-<p>As a side note, (((i use arch btw))) so everything here es aimed at an Arch Linux distro, and I'm doing everything on a VPS.</p>
+<p>As a side note, (((i use arch btw))) so everything here es aimed at an Arch Linux distro, and I'm doing everything on a VPS. Also note that most if not all commands here are executed with root privileges.</p>
<h2>Prerequisites</h2>
@@ -81,7 +81,7 @@
<ul>
<li>With <code>ssh</code> already configured both on the local machine and on the remote machine.</li>
-<li>Firewall already configured to allow ports 80 (http) and 443 (https). I use <code>ufw</code> so it's just a matter of doing <code>ufw allow 80,443/tcp</code> as root and you're golden.</li>
+<li>Firewall already configured to allow ports 80 (HTTP) and 443 (HTTPS). I use <code>ufw</code> so it's just a matter of doing <code>ufw allow 80,443/tcp</code> as root and you're golden.</li>
<li><code>cron</code> installed if you follow along (you could use <code>systemd</code> timers, or some other method you prefer to automate running commands every X time).</li>
</ul></li>
</ul>
@@ -90,9 +90,9 @@
<p>You have two options: <code>nginx</code> and <code>nginx-mainline</code>. I prefer <code>nginx-mainline</code> because it's the &#8220;up to date&#8221; package even though <code>nginx</code> is labeled to be the &#8220;stable&#8221; version. Install the package and enable/start the service:</p>
-<pre><code class="language-sh"># pacman -S nginx-mainline
-# systemctl enable nginx.service
-# systemctl start nginx.service
+<pre><code class="language-sh">pacman -S nginx-mainline
+systemctl enable nginx.service
+systemctl start nginx.service
</code></pre>
<p>And that's it, at this point you can already look at the default initial page of nginx if you enter the ip of your server in a web browser. You should see something like this:</p>
@@ -101,7 +101,7 @@
<p>As stated in the welcome page, configuration is needed, head to the directory of nginx:</p>
-<pre><code class="language-sh"># cd /etc/nginx
+<pre><code class="language-sh">cd /etc/nginx
</code></pre>
<p>Here you have several files, the important one is <code>nginx.conf</code>, which as its name implies, contains general configuration of the web server. If you peek into the file, you will see that it contains around 120 lines, most of which are commented out and contains the welcome page server block. While you can configure a website in this file, it's common practice to do it on a separate file (so you can scale really easily if needed for mor websites or sub-domains).</p>
@@ -129,9 +129,9 @@ http {
<p>Next, inside the directory <code>/etc/nginx/</code> create the <code>sites-available</code> and <code>sites-enabled</code>, and go into the <code>sites-available</code> one:</p>
-<pre><code class="language-sh"># mkdir sites-available
-# mkdir sites-enabled
-# cd sites-available
+<pre><code class="language-sh">mkdir sites-available
+mkdir sites-enabled
+cd sites-available
</code></pre>
<p>Here, create a new <code>.conf</code> file for your website and add the following lines (this is just the sample content more or less):</p>
@@ -166,15 +166,15 @@ http {
<p>Then, make a symbolic from this config file to the <code>sites-enabled</code> directory:</p>
-<pre><code class="language-sh"># ln -s /etc/nginx/sites-available/your_config_file.conf /etc/nginx/sites-enabled
+<pre><code class="language-sh">ln -s /etc/nginx/sites-available/your_config_file.conf /etc/nginx/sites-enabled
</code></pre>
<p>This is so the <code>nginx.conf</code> file can look up the newly created server config. With this method of having each server configuration file separate you can easily &#8220;deactivate&#8221; any website by just deleting the symbolic link in <code>sites-enabled</code> and you're good, or just add new configuration files and keep everything nice and tidy.</p>
<p>All you have to do now is restart (or enable and start if you haven't already) the nginx service (and optionally test the configuration):</p>
-<pre><code class="language-sh"># nginx -t
-# systemctl restart nginx
+<pre><code class="language-sh">nginx -t
+systemctl restart nginx
</code></pre>
<p>If everything goes correctly, you can now go to your website by typing &#8220;domain.name&#8221; on a web browser. But you will see a &#8220;404 Not Found&#8221; page like the following (maybe with different nginx version):</p>
@@ -200,19 +200,19 @@ http {
<p>The only &#8220;bad&#8221; (bloated) thing about certbot, is that it uses <code>python</code>, but for me it doesn't matter too much. You may want to look up another alternative if you prefer. Install the packages <code>certbot</code> and <code>certbot-nginx</code>:</p>
-<pre><code class="language-sh"># pacman -S certbot certbot-nginx
+<pre><code class="language-sh">pacman -S certbot certbot-nginx
</code></pre>
<p>After that, all you have to do now is run <code>certbot</code> and follow the instructions given by the tool:</p>
-<pre><code class="language-sh"># certbot --nginx
+<pre><code class="language-sh">certbot --nginx
</code></pre>
<p>It will ask you for some information, for you to accept some agreements and the names to activate https for. Also, you will want to &#8220;say yes&#8221; to the redirection from http to https. And that's it, you can now go to your website and see that you have https active.</p>
-<p>Now, the certificate given by certbot expires every 3 months or something like that, so you want to renew this certificate every once in a while. Using <code>cron</code>, you can do this by running:</p>
+<p>Now, the certificate given by <code>certbot</code> expires every 3 months or something like that, so you want to renew this certificate every once in a while. Using <code>cron</code>, you can do this by running:</p>
-<pre><code class="language-sh"># crontab -e
+<pre><code class="language-sh">crontab -e
</code></pre>
<p>And a file will be opened where you need to add a new rule for certbot, just append the line: <code>1 1 1 * * certbot renew</code> (renew on the first day of every month) and you're good. Alternatively use <code>systemd</code> timers as stated in the <a href="https://wiki.archlinux.org/index.php/Certbot#Automatic_renewal">Arch Linux Wiki</a>.</p>
@@ -223,7 +223,7 @@ http {
<div class=timestamp>
<hr>
-<p>Created: Sat, Mar 13, 2021 @ 23:08 MST</p>
+<p>Created: Thu, Mar 18, 2021 @ 19:58 MST</p>
</div>
<footer class="footer">
<i class="fas fa-envelope" alt="Email"></i>