website/tags/self-hosting/atom.xml

466 lines
47 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title> - self-hosting</title>
<link href="https://librepages.org/tags/self-hosting/atom.xml" rel="self" type="application/atom+xml"/>
<link href="https://librepages.org"/>
<generator uri="https://www.getzola.org/">Zola</generator>
<updated>2022-12-31T00:00:00+00:00</updated>
<id>https://librepages.org/tags/self-hosting/atom.xml</id>
<entry xml:lang="en">
<title>December 2022 Monthly Report</title>
<published>2022-12-31T00:00:00+00:00</published>
<updated>2022-12-31T00:00:00+00:00</updated>
<link href="https://librepages.org/blog/december-2022-monthly-report/" type="text/html"/>
<id>https://librepages.org/blog/december-2022-monthly-report/</id>
<content type="html">&lt;p&gt;These past couple of months have been very busy interesting, LibrePages
went from being a simple &lt;code&gt;git pull&lt;&#x2F;code&gt; webhook to fully-fledged platform
that can deploy static sites from &lt;em&gt;any&lt;&#x2F;em&gt; Git forge.&lt;&#x2F;p&gt;
&lt;p&gt;This month, the following things were accomplished:&lt;&#x2F;p&gt;
&lt;h2 id=&quot;1-deploy-site-from-dashboard&quot;&gt;1. Deploy site from dashboard&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-deploy-site-from-dashboard&quot; aria-label=&quot;Anchor link for: 1-deploy-site-from-dashboard&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;It is now possible to deploy and manage websites with log inspection
right from the dashboard. LibrePages will automatically assign a
randomly generated, but friendly-sounding subdomain on a domain that the
LibrePages system manages. It is also possible to inspect deployment
events, like site updates, to troubleshoot errors in the deployment
pipelines.&lt;&#x2F;p&gt;
&lt;p&gt;Custom domain support isn&#x27;t available at the moment but will be
implemented soon.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;2-forms-support&quot;&gt;2. Forms support&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-forms-support&quot; aria-label=&quot;Anchor link for: 2-forms-support&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Forms are useful but creating a separate backed or relying on
privacy-invasive tech like Google Forms is very inconvenient. Popular
JAMStack platforms like Netlify provide forms support, so we thought
implementing forms support will be useful.&lt;&#x2F;p&gt;
&lt;p&gt;LibrePages Forms is a &lt;a href=&quot;https:&#x2F;&#x2F;git.batsense.net&#x2F;LibrePages&#x2F;forms&quot;&gt;separate
service&lt;&#x2F;a&gt; that can be
integrated into the system. It accepts form submissions in both JSON and
&lt;code&gt;application&#x2F;x-www-form-urlencode&lt;&#x2F;code&gt;. Adding it to your
LibrePages-deployed website is very simple, please see
&lt;a href=&quot;https:&#x2F;&#x2F;docs.librepages.org&#x2F;forms&#x2F;add&#x2F;&quot;&gt;here&lt;&#x2F;a&gt; for instructions.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;3-forgejo-and-gitea-integration&quot;&gt;3. Forgejo and Gitea integration&lt;a class=&quot;zola-anchor&quot; href=&quot;#3-forgejo-and-gitea-integration&quot; aria-label=&quot;Anchor link for: 3-forgejo-and-gitea-integration&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;LibrePages exposes an endpoint which users can call to update their
deployments. This allows us to support all types of Git-based forges. In
addition to the endpoint, we now expose a webhook that is compatible
with Forgejo and Gitea. This way, the deployment will automatically be
updated when a push event is received at the deployed branch, without the
user (or their CI) requiring to call the endpoint.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;4-sysadmin-logging-and-debugging&quot;&gt;4. Sysadmin: logging and debugging&lt;a class=&quot;zola-anchor&quot; href=&quot;#4-sysadmin-logging-and-debugging&quot; aria-label=&quot;Anchor link for: 4-sysadmin-logging-and-debugging&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;LibrePages is complicated system made of multiple services. It also uses
several third-party applications, like Nginx, to serve websites.
Debugging an issue that affecting multiple services used be complicated
but LibrePages now includes instrumentation to monitor with
&lt;a href=&quot;https:&#x2F;&#x2F;prometheus.io&quot;&gt;Prometheus&lt;&#x2F;a&gt; and provides distributed tracing via
OpenTelemetry-based based utilities like &lt;a href=&quot;https:&#x2F;&#x2F;www.jaegertracing.io&#x2F;&quot;&gt;Jagger&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;5-nginx-bind-and-let-s-encrypt&quot;&gt;5. Nginx, bind and Let&#x27;s Encrypt&lt;a class=&quot;zola-anchor&quot; href=&quot;#5-nginx-bind-and-let-s-encrypt&quot; aria-label=&quot;Anchor link for: 5-nginx-bind-and-let-s-encrypt&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;LibrePages is modular, it can be integrated into any existing system,
like &lt;a href=&quot;https:&#x2F;&#x2F;gna.org&quot;&gt;Gna!&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;enough.community&#x2F;&quot;&gt;Enough
Community&lt;&#x2F;a&gt; to provide static site hosting. We
do this using
&lt;a href=&quot;https:&#x2F;&#x2F;git.batsense.net&#x2F;LibrePages&#x2F;conductor&quot;&gt;Conductor&lt;&#x2F;a&gt;, which allows
LibrePages to integrate with multiple DNS servers&#x2F;providers, reverse
proxies and other third-party applications that LibrePages would depend
on.&lt;&#x2F;p&gt;
&lt;p&gt;Currently, we are working on supporting a system based on Nginx, Bind9 and Let&#x27;s Encrypt.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;6-infrastructure-as-code&quot;&gt;6. Infrastructure-as-Code&lt;a class=&quot;zola-anchor&quot; href=&quot;#6-infrastructure-as-code&quot; aria-label=&quot;Anchor link for: 6-infrastructure-as-code&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;git.batsense.net&#x2F;LibrePages&#x2F;Infrastructure-as-Code&quot;&gt;Infrastructure as code to deploy the full
system&lt;&#x2F;a&gt; is
being worked on. So far, we&#x27;ve implemented deploying a Debian server
using Terraform and libvirt. Installing and and configuring LibrePages
is being worked on.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;thanks&quot;&gt;Thanks&lt;a class=&quot;zola-anchor&quot; href=&quot;#thanks&quot; aria-label=&quot;Anchor link for: thanks&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;I would like to thank the &lt;a href=&quot;https:&#x2F;&#x2F;www.easter-eggs.com&#x2F;&quot;&gt;Easter-eggs&lt;&#x2F;a&gt;
for funding team for funding &lt;a href=&quot;https:&#x2F;&#x2F;forum.gna.org&#x2F;t&#x2F;5-000-contract-aravinth-manivannan-easter-eggs&#x2F;58&quot;&gt;my work on
LibrePages&lt;&#x2F;a&gt; &amp;lt;3&lt;&#x2F;p&gt;
</content>
</entry>
<entry xml:lang="en">
<title>How to deploy a website WITHOUT LibrePages</title>
<published>2022-09-10T00:00:00+00:00</published>
<updated>2022-09-10T00:00:00+00:00</updated>
<link href="https://librepages.org/blog/2022-09-10-how-to-publish-website-without-librepages/" type="text/html"/>
<id>https://librepages.org/blog/2022-09-10-how-to-publish-website-without-librepages/</id>
<content type="html">&lt;p&gt;In this &lt;del&gt;blog post&lt;&#x2F;del&gt; tutorial, I&#x27;ll show you how to deploy a personal
website. LibrePages automates everything that is discussed in this
tutorial and lets you focus on creating content. Automation is good
but knowing how to do it manually using industry standard
technologies always helps!&lt;&#x2F;p&gt;
&lt;p&gt;We will be using the following technologies to deploy our website:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;debian.org&quot;&gt;GNU&#x2F;Linux server(Debian)&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.nginx.com&#x2F;&quot;&gt;Nginx&lt;&#x2F;a&gt; (webs server)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;letsencrypt.org&#x2F;&quot;&gt;Let&#x27;s Encrypt&lt;&#x2F;a&gt; (for HTTPS)&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Let&#x27;s get started!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;1-setup-debian-gnu-linux&quot;&gt;1. Setup Debian GNU&#x2F;Linux&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-setup-debian-gnu-linux&quot; aria-label=&quot;Anchor link for: 1-setup-debian-gnu-linux&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;We are going to start with a fresh GNU&#x2F;Linux installation, you could get
one from a cloud provider like &lt;a href=&quot;https:&#x2F;&#x2F;www.digitalocean.com&quot;&gt;Digital
Ocean&lt;&#x2F;a&gt; (not affiliated).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-1-give-your-account-sudo-privileges&quot;&gt;1.1) Give your account &lt;code&gt;sudo&lt;&#x2F;code&gt; privileges&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-1-give-your-account-sudo-privileges&quot; aria-label=&quot;Anchor link for: 1-1-give-your-account-sudo-privileges&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;On GNU&#x2F;Linux systems, the &lt;code&gt;root&lt;&#x2F;code&gt; account is the most powerful user account.
It is good practice to avoid working as &lt;code&gt;root&lt;&#x2F;code&gt; since a careless mistake
could wipe the entire system out.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo&lt;&#x2F;code&gt; give the ability to execute commands with &lt;code&gt;root&lt;&#x2F;code&gt; capabilities
from a lower-privileged account. Let&#x27;s make our account sudo capable:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;su &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# become root
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# add `realaravinth`, my account` to `sudo` group to be able to use `sudo`
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;usermod -aG&lt;&#x2F;span&gt;&lt;span&gt; sudo realaravinth &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# my account is called `realaravinth`, replace it with yours
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;exit
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; exit
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Log out and log back in.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-2-install-and-setup-firewall-ufw&quot;&gt;1.2) Install and setup firewall(&lt;code&gt;ufw&lt;&#x2F;code&gt;)&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-2-install-and-setup-firewall-ufw&quot; aria-label=&quot;Anchor link for: 1-2-install-and-setup-firewall-ufw&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;wiki.ubuntu.com&#x2F;UncomplicatedFirewall&quot;&gt;Uncomplicated
Firewall(&lt;code&gt;ufw&lt;&#x2F;code&gt;)&lt;&#x2F;a&gt; is a
popular firewall that is easy to set up and maintain. For most
installations, this should be enough. System administrators use
firewalls to open only the ports that they think should receive traffic
from external networks. Without it, all ports will be open, causing a
security nightmare.&lt;&#x2F;p&gt;
&lt;p&gt;We will require standard SSH (22), and the standard web ports (80 and
443). A comprehensive list of services and the list of ports the listen
on is available at &lt;code&gt;&#x2F;etc&#x2F;services&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo apt update &amp;amp;&amp;amp; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;apt&lt;&#x2F;span&gt;&lt;span&gt; upgrade &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# update system
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo apt install ufw &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# we are using `ufw` for the firewall
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo ufw allow ssh &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# allow SSH traffic on port 22, required to log into the server
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo ufw enable &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# deploy firewall
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;1-3-secure-ssh&quot;&gt;1.3) Secure SSH&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-secure-ssh&quot; aria-label=&quot;Anchor link for: 1-3-secure-ssh&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;SSH allows remote access to our servers over secure, encrypted channels.
By default, users can log in with their password using SSH. But password
authentication &lt;a href=&quot;https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;title&#x2F;OpenSSH#Protecting_against_brute_force_attacks&quot;&gt;is susceptible to brute force
attacks&lt;&#x2F;a&gt;,
so we should &lt;a href=&quot;https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;title&#x2F;OpenSSH#Force_public_key_authentication&quot;&gt;disable password logins on our server and only allow
public-key authentication
only&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-3-1-generate-key-pair&quot;&gt;1.3.1) Generate key pair&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-1-generate-key-pair&quot; aria-label=&quot;Anchor link for: 1-3-1-generate-key-pair&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;On your local computer, generate an SSH key pair:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; ssh-keygen
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Generating&lt;&#x2F;span&gt;&lt;span&gt; public&#x2F;private rsa key pair.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Enter&lt;&#x2F;span&gt;&lt;span&gt; file in which to save the key (&#x2F;home&#x2F;realaravinth&#x2F;.ssh&#x2F;id_rsa)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Enter&lt;&#x2F;span&gt;&lt;span&gt; passphrase (empty for no passphrase)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Enter&lt;&#x2F;span&gt;&lt;span&gt; same passphrase again:
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Your&lt;&#x2F;span&gt;&lt;span&gt; identification has been saved in &#x2F;home&#x2F;realaravinth&#x2F;.ssh&#x2F;id_rsa
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Your&lt;&#x2F;span&gt;&lt;span&gt; public key has been saved in &#x2F;home&#x2F;realaravinth&#x2F;.ssh&#x2F;id_rsa.pub
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;The&lt;&#x2F;span&gt;&lt;span&gt; key fingerprint is:
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;SHA256:i2DE1b9BQb9DqV0r6O9MfPeVqUwfww1&#x2F;T8wIXL2Xqdo&lt;&#x2F;span&gt;&lt;span&gt; realaravinth@myserver.com
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;The&lt;&#x2F;span&gt;&lt;span&gt; key&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;s random art image is:
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;+---[RSA 3072]----+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| .. .o. |
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| . . . .. . . |
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| o o + o .|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| . o* + .+|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| o S ooB o+.|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| . . . o.. +o*=|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| . . . ooo*X|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| +=.ooB|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;| o+E .o|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;+----[SHA256]-----+
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Set a strong password the program prompts for one and save it somewhere
safe. Your public key will be at &lt;code&gt;~&#x2F;.ssh&#x2F;id_rsa.pub&lt;&#x2F;code&gt; and your private key at
&lt;code&gt;~&#x2F;.ssh&#x2F;id_rsa&lt;&#x2F;code&gt;. &lt;strong&gt;Never share the private key with anyone&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-3-2-setup-public-key-authentication&quot;&gt;1.3.2) Setup public-key authentication&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-2-setup-public-key-authentication&quot; aria-label=&quot;Anchor link for: 1-3-2-setup-public-key-authentication&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;We have to copy the public key that we generated in the previous setup
onto our server:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; ssh-copy-id&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -i ~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;.ssh&#x2F;id_rsa.pub myserver.com
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;&#x2F;usr&#x2F;bin&#x2F;ssh-copy-id:&lt;&#x2F;span&gt;&lt;span&gt; INFO: Source of key(s) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;to&lt;&#x2F;span&gt;&lt;span&gt; be installed: &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;home&#x2F;realaravinth&#x2F;.ssh&#x2F;id_rsa.pub&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;&#x2F;usr&#x2F;bin&#x2F;ssh-copy-id:&lt;&#x2F;span&gt;&lt;span&gt; INFO: attempting to log in with the new key(s)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; to filter out any that are already installed
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;&#x2F;usr&#x2F;bin&#x2F;ssh-copy-id:&lt;&#x2F;span&gt;&lt;span&gt; INFO: 1 key(s) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;remain&lt;&#x2F;span&gt;&lt;span&gt; to be installed -- if you are prompted now it is to install the new keys
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;realaravinth@myserver.com&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;s password:
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Number of key(s) added: 1
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Now try logging into the machine, with: &amp;quot;ssh &lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;myserver.com&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;and check to make sure that only the key(s) you wanted were added.
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;1-3-3-disable-ssh-password-authentication&quot;&gt;1.3.3) Disable SSH password authentication&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-3-disable-ssh-password-authentication&quot; aria-label=&quot;Anchor link for: 1-3-3-disable-ssh-password-authentication&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;NOTE: Verify you can log into your account before proceeding&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Now that we have a private-key authentication setup on both the client and
the server, let&#x27;s disable password authentication on the server:&lt;&#x2F;p&gt;
&lt;p&gt;Open &lt;code&gt;&#x2F;etc&#x2F;ssh&#x2F;sshd_config&lt;&#x2F;code&gt; and add the following lines:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;PubkeyAuthentication yes
&lt;&#x2F;span&gt;&lt;span&gt;PasswordAuthentication no
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And restart the SSH server:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo systemctl restart sshd
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;1-3-install-and-setup-fail2ban&quot;&gt;1.3) Install and setup &lt;code&gt;fail2ban&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-install-and-setup-fail2ban&quot; aria-label=&quot;Anchor link for: 1-3-install-and-setup-fail2ban&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;We will be using
&lt;a href=&quot;https:&#x2F;&#x2F;www.fail2ban.org&#x2F;wiki&#x2F;index.php&#x2F;Main_Page&quot;&gt;&lt;code&gt;fail2ban&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; for
intrusion prevention by blacklisting entities (users, bots, etc.) based
on failed login attempts.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;1-3-1-install-fail2ban&quot;&gt;1.3.1) Install &lt;code&gt;fail2ban&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-1-install-fail2ban&quot; aria-label=&quot;Anchor link for: 1-3-1-install-fail2ban&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo apt install fail2ban
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;1-3-2-enable-fail2ban-for-sshd&quot;&gt;1.3.2) Enable &lt;code&gt;fail2ban&lt;&#x2F;code&gt; for &lt;code&gt;sshd&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-2-enable-fail2ban-for-sshd&quot; aria-label=&quot;Anchor link for: 1-3-2-enable-fail2ban-for-sshd&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Open &lt;code&gt;fail2ban&lt;&#x2F;code&gt; configuration at &lt;code&gt;&#x2F;etc&#x2F;fail2ban&#x2F;jail.conf&lt;&#x2F;code&gt; and add the following lines:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yml&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-yml &quot;&gt;&lt;code class=&quot;language-yml&quot; data-lang=&quot;yml&quot;&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;sshd&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;enabled = true
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;1-3-3-configure-fail2ban-to-start-on-boot&quot;&gt;1.3.3) Configure &lt;code&gt;fail2ban&lt;&#x2F;code&gt; to start on boot&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-3-3-configure-fail2ban-to-start-on-boot&quot; aria-label=&quot;Anchor link for: 1-3-3-configure-fail2ban-to-start-on-boot&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo systemctl enable fail2ban
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo systemctl start fail2ban
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;1-4-install-and-setup-nginx&quot;&gt;1.4) Install and setup &lt;code&gt;nginx&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-4-install-and-setup-nginx&quot; aria-label=&quot;Anchor link for: 1-4-install-and-setup-nginx&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;nginx&lt;&#x2F;code&gt; is a popular web server that can be used to serve static sites.
It is fast, stable, and easy to set up.&lt;&#x2F;p&gt;
&lt;p&gt;To install, run the following command:&lt;&#x2F;p&gt;
&lt;h4 id=&quot;1-4-1-install-nginx&quot;&gt;1.4.1) Install &lt;code&gt;nginx&lt;&#x2F;code&gt;:&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-4-1-install-nginx&quot; aria-label=&quot;Anchor link for: 1-4-1-install-nginx&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo apt install nginx
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;1-4-2-allow-web-traffic-open-ports-80-and-443&quot;&gt;1.4.2) Allow web traffic: open ports &lt;code&gt;80&lt;&#x2F;code&gt; and &lt;code&gt;443&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-4-2-allow-web-traffic-open-ports-80-and-443&quot; aria-label=&quot;Anchor link for: 1-4-2-allow-web-traffic-open-ports-80-and-443&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Ports &lt;code&gt;80&lt;&#x2F;code&gt; is the default for HTTP and &lt;code&gt;443&lt;&#x2F;code&gt; for HTTPS. To serve
web traffic, we&#x27;ll have to Configure &lt;code&gt;ufw&lt;&#x2F;code&gt; to accept traffic on them:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo ufw allow 80 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# open ports 80 HTTP traffic
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo ufw allow 443 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# open ports 443 for HTTPS traffic
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;1-4-2-configure-nginx-to-start-on-boot&quot;&gt;1.4.2) Configure &lt;code&gt;nginx&lt;&#x2F;code&gt; to start on boot&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-4-2-configure-nginx-to-start-on-boot&quot; aria-label=&quot;Anchor link for: 1-4-2-configure-nginx-to-start-on-boot&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo systemctl enable nginx &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# automatically start nginx on boot
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo systemctl start nginx &lt;&#x2F;span&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# start nginx server
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And verify it works:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; curl localhost
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;!DOCTYPE &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;html&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;html&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;head&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;title&amp;gt;Welcome &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;to&lt;&#x2F;span&gt;&lt;span&gt; nginx!&amp;lt;&#x2F;title&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;style&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;body &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt; width: 35em;
&lt;&#x2F;span&gt;&lt;span&gt; margin: 0 auto;
&lt;&#x2F;span&gt;&lt;span&gt; font-family: Tahoma, Verdana, Arial, sans-serif;
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;style&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;head&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;body&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;h1&amp;gt;Welcome &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;to&lt;&#x2F;span&gt;&lt;span&gt; nginx!&amp;lt;&#x2F;h1&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;If &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;you&lt;&#x2F;span&gt;&lt;span&gt; see this page, the nginx web server is successfully installed and
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;working.&lt;&#x2F;span&gt;&lt;span&gt; Further configuration is required.&amp;lt;&#x2F;p&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;For &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;online&lt;&#x2F;span&gt;&lt;span&gt; documentation and support please refer to
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;a &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;href&lt;&#x2F;span&gt;&lt;span&gt;=&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;http:&#x2F;&#x2F;nginx.org&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;&amp;gt;nginx.org&amp;lt;&#x2F;a&amp;gt;.&amp;lt;br&#x2F;&amp;gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Commercial&lt;&#x2F;span&gt;&lt;span&gt; support is available at
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;a &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;href&lt;&#x2F;span&gt;&lt;span&gt;=&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;http:&#x2F;&#x2F;nginx.com&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;&amp;gt;nginx.com&amp;lt;&#x2F;a&amp;gt;.&amp;lt;&#x2F;p&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;p&amp;gt;&amp;lt;em&amp;gt;Thank &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;you&lt;&#x2F;span&gt;&lt;span&gt; for using nginx.&amp;lt;&#x2F;em&amp;gt;&amp;lt;&#x2F;p&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;body&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;html&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;nginx&lt;&#x2F;code&gt; is working!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;2-deploy-website&quot;&gt;2) Deploy website&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-deploy-website&quot; aria-label=&quot;Anchor link for: 2-deploy-website&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;For this demo, we&#x27;ll deploy a single file(&lt;code&gt;index.html&lt;&#x2F;code&gt;)
HTML website.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-1-install-the-webpage-on-the-server&quot;&gt;2.1) Install the webpage on the server&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-1-install-the-webpage-on-the-server&quot; aria-label=&quot;Anchor link for: 2-1-install-the-webpage-on-the-server&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;Edit &lt;code&gt;&#x2F;var&#x2F;www&#x2F;html&#x2F;index.html&lt;&#x2F;code&gt; and add the following HTML to it:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;html&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-html &quot;&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span&gt;&amp;lt;!&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;DOCTYPE &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;html&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;html&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;head&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;title&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;My cool website!&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;title&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;head&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;body&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;h1&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;Welcome to my website! o&#x2F;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;h1&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;body&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;html&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The webpage should now be available on localhost, and we should see it when we run the following command:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; curl localhost
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;!DOCTYPE &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;html&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;html&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;head&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;title&amp;gt;My &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cool&lt;&#x2F;span&gt;&lt;span&gt; website!&amp;lt;&#x2F;title&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&#x2F;head&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;body&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;h1&amp;gt;Welcome &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;to&lt;&#x2F;span&gt;&lt;span&gt; my website! o&#x2F;&amp;lt;&#x2F;h1&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;&#x2F;body&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&#x2F;html&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;2-2-serve-webpage-on-a-custom-domain&quot;&gt;2.2) Serve webpage on a custom domain&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-2-serve-webpage-on-a-custom-domain&quot; aria-label=&quot;Anchor link for: 2-2-serve-webpage-on-a-custom-domain&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;2-2-1-buy-a-domain-if-you-don-t-own-one-already&quot;&gt;2.2.1) Buy a domain if you don&#x27;t own one already&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-2-1-buy-a-domain-if-you-don-t-own-one-already&quot; aria-label=&quot;Anchor link for: 2-2-1-buy-a-domain-if-you-don-t-own-one-already&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;h4 id=&quot;2-2-2-go-to-the-domain-s-dns-dashboard-and-add-the-following-record&quot;&gt;2.2.2) Go to the domain&#x27;s DNS dashboard and add the following record&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-2-2-go-to-the-domain-s-dns-dashboard-and-add-the-following-record&quot; aria-label=&quot;Anchor link for: 2-2-2-go-to-the-domain-s-dns-dashboard-and-add-the-following-record&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;@ A 300 &amp;lt;your server IP address&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;2-2-3-setup-nginx-to-serve-the-website-at-http-your-domain&quot;&gt;2.2.3) Setup &lt;code&gt;nginx&lt;&#x2F;code&gt; to serve the website at &lt;code&gt;http:&#x2F;&#x2F;&amp;lt;your-domain&amp;gt;&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-2-3-setup-nginx-to-serve-the-website-at-http-your-domain&quot; aria-label=&quot;Anchor link for: 2-2-3-setup-nginx-to-serve-the-website-at-http-your-domain&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Open &lt;code&gt;&#x2F;etc&#x2F;nginx&#x2F;sites-available&#x2F;your-domain&lt;&#x2F;code&gt; and add the following:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;server {
&lt;&#x2F;span&gt;&lt;span&gt; # serve website on port 80
&lt;&#x2F;span&gt;&lt;span&gt; listen [::]:80;
&lt;&#x2F;span&gt;&lt;span&gt; listen 80;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; # write error logs to file
&lt;&#x2F;span&gt;&lt;span&gt; error_log &#x2F;var&#x2F;log&#x2F;nginx&#x2F;&amp;lt;your-domain&amp;gt;.error.log;
&lt;&#x2F;span&gt;&lt;span&gt; # write access logs to file
&lt;&#x2F;span&gt;&lt;span&gt; access_log &#x2F;var&#x2F;log&#x2F;nginx&#x2F;&amp;lt;your-domain&amp;gt;.access.log;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; # serve only on this domain:
&lt;&#x2F;span&gt;&lt;span&gt; server_name &amp;lt;your-domain&amp;gt;; # replace me
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; # use files from this directory
&lt;&#x2F;span&gt;&lt;span&gt; root &#x2F;var&#x2F;www&#x2F;html&#x2F;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; # remove .html from URL; it is cleaner this way
&lt;&#x2F;span&gt;&lt;span&gt; rewrite ^(&#x2F;.*)\.html(\?.*)?$ $1$2 permanent;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; # when a request is received, try the index.html in the directory
&lt;&#x2F;span&gt;&lt;span&gt; # or $uri.html
&lt;&#x2F;span&gt;&lt;span&gt; try_files $uri&#x2F;index.html $uri.html $uri&#x2F; $uri =404;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It is good practice to have all &lt;code&gt;nginx&lt;&#x2F;code&gt; deployment configurations in
&lt;code&gt;&#x2F;etc&#x2F;nginx&#x2F;sites-available&#x2F;&lt;&#x2F;code&gt; directory and link production websites to
`&#x2F;etc&#x2F;nginx&#x2F;sites-enabled directory. Doing so allows you to
work-in-progress configurations or delete deployments without losing
the configuration files.&lt;&#x2F;p&gt;
&lt;p&gt;Let&#x27;s enable &lt;code&gt;&amp;lt;your-domain&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo ln&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -s&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;etc&#x2F;nginx&#x2F;sites-available&#x2F;&amp;lt;your-domain&amp;gt; &#x2F;etc&#x2F;nginx&#x2F;sites-enabled&#x2F;&amp;lt;your-domain&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Verify configurations before deploying, &lt;code&gt;nginx&lt;&#x2F;code&gt; has a command
to do it:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo nginx&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -t
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If there are no errors, reload &lt;code&gt;nginx&lt;&#x2F;code&gt; to deploy the website:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo nginx&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -s&lt;&#x2F;span&gt;&lt;span&gt; reload
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Your webpage should now be accessible at &lt;code&gt;http:&#x2F;&#x2F;&amp;lt;your-domain&amp;gt;&lt;&#x2F;code&gt;!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-3-install-certbot-to-set-up-https&quot;&gt;2.3) Install &lt;code&gt;certbot&lt;&#x2F;code&gt; to set up HTTPS&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-3-install-certbot-to-set-up-https&quot; aria-label=&quot;Anchor link for: 2-3-install-certbot-to-set-up-https&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;HTTP is insecure. We&#x27;ll have to set up SSL to serve our website using
HTTPS. To do that, we will be using &lt;a href=&quot;https:&#x2F;&#x2F;letsencrypt.org&#x2F;&quot;&gt;Let&#x27;s
Encrypt&lt;&#x2F;a&gt; a popular nonprofit certificate
authority to get our SSL certificates.&lt;&#x2F;p&gt;
&lt;p&gt;SSL certificates come with set lifetimes, so we renew them before they expire. The process, when done manually, is demanding: you
will have to log in every three months and renew the
certificate. If you fail or forget it, your visitors will see security
warnings on your website.&lt;&#x2F;p&gt;
&lt;p&gt;Thankfully, there is a way to automate this process through
&lt;a href=&quot;https:&#x2F;&#x2F;certbot.eff.org&#x2F;&quot;&gt;&lt;code&gt;certbot&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h4 id=&quot;2-3-1-install-certbot&quot;&gt;2.3.1) Install &lt;code&gt;certbot&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-3-1-install-certbot&quot; aria-label=&quot;Anchor link for: 2-3-1-install-certbot&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo apt install certbot python3-certbot-nginx
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;2-3-2-get-a-certificate-for-your-domain&quot;&gt;2.3.2) Get a certificate for &lt;code&gt;&amp;lt;your-domain&amp;gt;&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-3-2-get-a-certificate-for-your-domain&quot; aria-label=&quot;Anchor link for: 2-3-2-get-a-certificate-for-your-domain&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; sudo certbot&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; --nginx -d &lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;your-domain&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;certbot&lt;&#x2F;code&gt; will prompt you for an email ID, and ask you to accept their
terms and conditions, privacy policy, etc. Be sure to read them before
agreeing to them. It will then try to authenticate your domain ownership
using the &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Automatic_Certificate_Management_Environment&quot;&gt;ACME
protocol&lt;&#x2F;a&gt;.
By configuring the DNS to point to our server and by telling &lt;code&gt;nginx&lt;&#x2F;code&gt; at
that domain.&lt;&#x2F;p&gt;
&lt;p&gt;When it has verified ownership, it will automatically issue, deploy the
certificate on &lt;code&gt;nginx&lt;&#x2F;code&gt; and setup redirects.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;2-3-3-setup-cronjob-to-automate-ssl-certificate-renewals&quot;&gt;2.3.3) Setup cronjob to automate SSL certificate renewals&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-3-3-setup-cronjob-to-automate-ssl-certificate-renewals&quot; aria-label=&quot;Anchor link for: 2-3-3-setup-cronjob-to-automate-ssl-certificate-renewals&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Become root and edit crontab&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; su
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;crontab -e
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Add the following job and exit:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;0 *&#x2F;12 * * * certbot -n --nginx renew
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It will attempt to renew SSL certificates every 12 hours. If a the
certificate is due for renewal, &lt;code&gt;certbot&lt;&#x2F;code&gt; will go through the ACME
challenge, get the new certificates and automatically deploy them for
you.&lt;&#x2F;p&gt;
&lt;p&gt;Now our GNU&#x2F;Linux server is configured and ready to serve our website at
&lt;code&gt;http:&#x2F;&#x2F;&amp;lt;your-website&amp;gt;&lt;&#x2F;code&gt;!&lt;&#x2F;p&gt;
</content>
</entry>
</feed>