Files
blog-ahmza-com/public/posts/setup-an-nginx-reverse-proxy/index.html
T
2023-11-10 23:24:28 +00:00

59 lines
28 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html><html lang=en dir=auto><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=robots content="index, follow"><title>Setup an NGINX Reverse Proxy 🥸 | ahmza's ramblings</title>
<meta name=keywords content="HomeLab,Networking,NGINX,ReverseProxy"><meta name=description content="Learn to setup a quick and easy reverse proxy using NGINX"><meta name=author content="ahmza"><link rel=canonical href=https://blog.ahmza.com/Page%28/posts/Setup-an-NGINX-Reverse-Proxy.md%29><link crossorigin=anonymous href=/assets/css/stylesheet.49e35863ac4b53ab71c7e3249dd5e722c701ee07f8d0cb006a4f4e954364b6fe.css integrity="sha256-SeNYY6xLU6txx+MkndXnIscB7gf40MsAak9OlUNktv4=" rel="preload stylesheet" as=style><script defer crossorigin=anonymous src=/assets/js/highlight.f413e19d0714851f6474e7ee9632408e58ac146fbdbe62747134bea2fa3415e0.js integrity="sha256-9BPhnQcUhR9kdOfuljJAjlisFG+9vmJ0cTS+ovo0FeA=" onload=hljs.initHighlightingOnLoad()></script><link rel=icon href=https://blog.ahmza.com/img/favicon.png><link rel=icon type=image/png sizes=16x16 href=https://blog.ahmza.com/img/favicon.png><link rel=icon type=image/png sizes=32x32 href=https://blog.ahmza.com/img/favicon.png><link rel=apple-touch-icon href=https://blog.ahmza.com/img/favicon.png><link rel=mask-icon href=https://blog.ahmza.com/img/favicon.png><meta name=theme-color content="#2e2e33"><meta name=msapplication-TileColor content="#2e2e33"><noscript><style>#theme-toggle,.top-link{display:none}</style></noscript><script async src="https://www.googletagmanager.com/gtag/js?id=G-HSJHLHP8FZ"></script><script>var doNotTrack=!1;if(!doNotTrack){window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag("js",new Date),gtag("config","G-HSJHLHP8FZ",{anonymize_ip:!1})}</script><meta property="og:title" content="Setup an NGINX Reverse Proxy 🥸"><meta property="og:description" content="Learn to setup a quick and easy reverse proxy using NGINX"><meta property="og:type" content="article"><meta property="og:url" content="https://blog.ahmza.com/posts/setup-an-nginx-reverse-proxy/"><meta property="og:image" content="https://blog.ahmza.com/webp/posts/reverse-proxy/feature-anim.webp"><meta property="article:section" content="posts"><meta property="article:published_time" content="2021-12-01T22:59:00+00:00"><meta property="article:modified_time" content="2021-12-01T22:59:00+00:00"><meta property="og:site_name" content="ahmza's ramblings"><meta name=twitter:card content="summary_large_image"><meta name=twitter:image content="https://blog.ahmza.com/webp/posts/reverse-proxy/feature-anim.webp"><meta name=twitter:title content="Setup an NGINX Reverse Proxy 🥸"><meta name=twitter:description content="Learn to setup a quick and easy reverse proxy using NGINX"><script type=application/ld+json>{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":2,"name":"Posts","item":"https://blog.ahmza.com/posts/"},{"@type":"ListItem","position":3,"name":"Setup an NGINX Reverse Proxy 🥸","item":"https://blog.ahmza.com/posts/setup-an-nginx-reverse-proxy/"}]}</script><script type=application/ld+json>{"@context":"https://schema.org","@type":"BlogPosting","headline":"Setup an NGINX Reverse Proxy 🥸","name":"Setup an NGINX Reverse Proxy 🥸","description":"Learn to setup a quick and easy reverse proxy using NGINX","keywords":["HomeLab","Networking","NGINX","ReverseProxy"],"articleBody":"Introduction In this post we will go over setting up an NGINX reverse proxy to allow different web services to reach the outside world. We will also cover setting up auto renewing SSL certificates.\nWhy not just port forward the services, it does the same thing Right? Reverse proxies are a great way to expose web services to the outside world in a more secure and customisable manner. Some of the features that a reverse proxy provides are as follows:\nHost multiple services using the same HTTP/HTTPS ports Hides the origin server HTTPS TLS encryption Caching Compression Creating a Reverse Proxy Prerequisites a server to act as the reverse proxy a web server a registered domain name Have A records setup for the Domain name Install NGINX I’ll be using the apt package manager as I’m on Ubuntu server, this may differ for you\nUpdate packages, then install NGINX\nsudo apt update sudo apt install nginx Now we want to enable NGINX so the program will start when the server boots\nsudo systemctl enable --now nginx Firewall Quick Note: now is a good time to port forward ports 80 and 443 from the router to the reverse proxy\nUbuntu server comes with a firewall (ufw), so be sure to allow access to NGINX and enable it.\nThe reverse proxy handles both HTTP and HTTPS so allow “Nginx Full”\nsudo ufw allow 'Nginx full' If you are using SSH allow it through\nsudo ufw allow 'OpenSSH' Configure NGINX Unlink the default NGINX config\nsudo unlink /etc/nginx/sites-enabled/default Create NGINX Config Create a config file in /etc/nginx/site-available\nQuick Note: use whichever text editor you want, I’m using vim\nsudo vim /etc/nginx/sites-available/blog.conf server { listen 80; server_name blog.example.com; location / { proxy_pass http://ip-of-server:port; } } server_name is the domain name you want use this can include sub-domains proxy_pass is the IP address of the web server Enable NGINX Config To activate a config file we need to link the file from the sites-available folder to sites-enabled.\nPro Tip: make sure to use full paths when creating symlinks\nsudo ln -s /etc/nginx/sites-available/blog.conf /etc/nginx/sites-enabled/blog.conf Check the config, this is an important step as it warns you of any errors before reloading NGINX\nsudo nginx -t If the output looks simmiler to below then you’re good to go !!\nnginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful Now restart the NGINX service\nsudo systemctl restart nginx you should now have a working reverse proxy !!\nSetting up SSL Prerequisites Make sure HTTP and HTTPS are port forwarded to the reverse proxy Make sure server_name is set in the config file you created Installing Certbot Certbot is a tool that requests an SSL certificate and makes sure it is renewed when needed. Install Certbot as well as the python NGINX plug-in\nsudo apt install certbot python3-certbot-nginx Quick Note: double check firewall rules\nRequest SSL Certificate Now all we need to do is request the certificate !!\nsudo certbot --nginx -d blog.example.com –nginx specifies we are using NGINX, this will update the config file we created to allow the use of SSL -d is the domain name you want to use If this is the first time running Certbot you will be asked to enter an email as well as agree to terms and services.\nIf the certificate request is successful you will be prompted with\nPlease choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): If you want all traffic to be SSL encrypted choose option 2 That’s it we have SSL certificates installed. You will need a new certificate for each different domain name or subdomain.\nVerify Auto Renewal All we need to do now is make sure that Certbot can automatically renew certificates.\nsudo certbot renew --dry-run If you see no errors then you are ready to go.\nConclusion By following this you have hopefully managed to setup an NGINX Reverse proxy to handle incoming HTTP/HTTPS requests as well as configured automatically renewing SSL certificates.\nThis posts barely scratches the surface of what NGINX can do, I would highly recommend reading more into this great piece of software !!\nMy reverse proxy handling non existent traffic\nGive it a few months and this blog will …\n","wordCount":"850","inLanguage":"en","image":"https://blog.ahmza.com/webp/posts/reverse-proxy/feature-anim.webp","datePublished":"2021-12-01T22:59:00Z","dateModified":"2021-12-01T22:59:00Z","author":{"@type":"Person","name":"ahmza"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://blog.ahmza.com/posts/setup-an-nginx-reverse-proxy/"},"publisher":{"@type":"Organization","name":"ahmza's ramblings","logo":{"@type":"ImageObject","url":"https://blog.ahmza.com/img/favicon.png"}}}</script></head><body class=dark id=top><script>localStorage.getItem("pref-theme")==="light"&&document.body.classList.remove("dark")</script><header class=header><nav class=nav><div class=logo><a href=https://blog.ahmza.com accesskey=h title="ahmza's ramblings (Alt + H)">ahmza's ramblings</a><div class=logo-switches><button id=theme-toggle accesskey=t title="(Alt + T)"><svg id="moon" xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg><svg id="sun" xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg></button></div></div><ul id=menu><li><a href=https://blog.ahmza.com/posts/ title=posts><span>posts</span></a></li><li><a href=https://blog.ahmza.com/archives/ title=archive><span>archive</span></a></li><li><a href=https://blog.ahmza.com/tags/ title=tags><span>tags</span></a></li><li><a href=https://blog.ahmza.com/contact title=contact><span>contact</span></a></li><li><a href=https://blog.ahmza.com/search/ title="search (Alt + /)" accesskey=/><span>search</span></a></li></ul></nav></header><main class=main><article class=post-single><header class=post-header><div class=breadcrumbs><a href=https://blog.ahmza.com>Home</a>&nbsp;»&nbsp;<a href=https://blog.ahmza.com/posts/>Posts</a></div><h1 class=post-title>Setup an NGINX Reverse Proxy 🥸</h1><div class=post-description>Learn to setup a quick and easy reverse proxy using NGINX</div><div class=post-meta>&lt;span title='2021-12-01 22:59:00 +0000 UTC'>December 1, 2021&lt;/span>&amp;nbsp;·&amp;nbsp;4 min&amp;nbsp;·&amp;nbsp;850 words&amp;nbsp;·&amp;nbsp;ahmza&nbsp;|&nbsp;<a href=https://gitlab.com/AHMZA/blog/-/blob/main/content/posts/Setup-an-NGINX-Reverse-Proxy.md rel="noopener noreferrer" target=_blank>Suggest Changes</a></div></header><figure class=entry-cover><img loading=lazy src=https://blog.ahmza.com/webp/posts/reverse-proxy/feature-anim.webp alt="abstracted reverse proxy diagram"><p></p></figure><div class=toc><details><summary accesskey=c title="(Alt + C)"><span class=details>Table of Contents</span></summary><div class=inner><ul><li><a href=#introduction aria-label=Introduction><strong>Introduction</strong></a></li><li><a href=#creating-a-reverse-proxy aria-label="Creating a Reverse Proxy"><strong>Creating a Reverse Proxy</strong></a><ul><li><a href=#prerequisites aria-label=Prerequisites><strong>Prerequisites</strong></a></li><li><a href=#install-nginx aria-label="Install NGINX"><strong>Install</strong> <em><strong>NGINX</strong></em></a></li></ul></li><li><a href=#firewall aria-label=Firewall><strong>Firewall</strong></a></li><li><a href=#configure-nginx aria-label="Configure NGINX"><strong>Configure</strong> <em><strong>NGINX</strong></em></a><ul><li><a href=#create-nginx-config aria-label="Create NGINX Config"><strong>Create <em><strong>NGINX</strong></em> Config</strong></a></li><li><a href=#enable-nginx-config aria-label="Enable NGINX Config"><strong>Enable <em><strong>NGINX</strong></em> Config</strong></a></li></ul></li><li><a href=#setting-up-ssl aria-label="Setting up SSL"><strong>Setting up SSL</strong></a><ul><li><a href=#prerequisites-1 aria-label=Prerequisites><strong>Prerequisites</strong></a></li><li><a href=#installing-certbot aria-label="Installing Certbot"><strong>Installing</strong> <em><strong>Certbot</strong></em></a></li><li><a href=#request-ssl-certificate aria-label="Request SSL Certificate"><strong>Request SSL Certificate</strong></a></li><li><a href=#verify-auto-renewal aria-label="Verify Auto Renewal"><strong>Verify Auto Renewal</strong></a></li></ul></li><li><a href=#conclusion aria-label=Conclusion><strong>Conclusion</strong></a></li></ul></div></details></div><div class=post-content><h1 id=introduction><strong>Introduction</strong><a hidden class=anchor aria-hidden=true href=#introduction>#</a></h1><p>In this post we will go over setting up an <em>NGINX</em> reverse proxy to
<strong>allow different web services to reach the outside world.</strong> We will
also cover setting up <strong>auto renewing SSL certificates.</strong></p><p>Why not just port forward the services, it does the same thing Right?
Reverse proxies are a great way to expose web services to the outside
world in a more secure and customisable manner. <strong>Some of the features
that a reverse proxy provides are as follows:</strong></p><ul><li><strong>Host multiple services using the same HTTP/HTTPS ports</strong></li><li><strong>Hides the origin server</strong></li><li><strong>HTTPS TLS encryption</strong></li><li><strong>Caching</strong></li><li><strong>Compression</strong></li></ul><h1 id=creating-a-reverse-proxy><strong>Creating a Reverse Proxy</strong><a hidden class=anchor aria-hidden=true href=#creating-a-reverse-proxy>#</a></h1><h2 id=prerequisites><strong>Prerequisites</strong><a hidden class=anchor aria-hidden=true href=#prerequisites>#</a></h2><ul><li><strong>a server to act as the reverse proxy</strong></li><li><strong>a web server</strong></li><li><strong>a registered domain name</strong></li><li><strong>Have A records setup for the Domain name</strong></li></ul><h2 id=install-nginx><strong>Install</strong> <em><strong>NGINX</strong></em><a hidden class=anchor aria-hidden=true href=#install-nginx>#</a></h2><p>I&rsquo;ll be using the apt package manager as I&rsquo;m on Ubuntu server,
this may differ for you</p><p>Update packages, then <strong>install</strong> <em><strong>NGINX</strong></em></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo apt update
</span></span><span class=line><span class=cl>sudo apt install nginx
</span></span></code></pre></div><p>Now we want to <strong>enable</strong> <em><strong>NGINX</strong></em> so the program will start when
the server boots</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo systemctl <span class=nb>enable</span> --now nginx
</span></span></code></pre></div><h1 id=firewall><strong>Firewall</strong><a hidden class=anchor aria-hidden=true href=#firewall>#</a></h1><blockquote><p><strong>Quick Note:</strong> now is a good time to port forward ports 80 and 443
from the router to the reverse proxy</p></blockquote><p>Ubuntu server comes with a firewall (ufw), so be sure to allow access
to <em>NGINX</em> and enable it.</p><p>The reverse proxy handles both HTTP and HTTPS so <strong>allow &ldquo;Nginx Full&rdquo;</strong></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo ufw allow <span class=s1>&#39;Nginx full&#39;</span>
</span></span></code></pre></div><p><strong>If you are using SSH allow it through</strong></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo ufw allow <span class=s1>&#39;OpenSSH&#39;</span>
</span></span></code></pre></div><h1 id=configure-nginx><strong>Configure</strong> <em><strong>NGINX</strong></em><a hidden class=anchor aria-hidden=true href=#configure-nginx>#</a></h1><p><strong>Unlink the default <em><strong>NGINX</strong></em> config</strong></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo unlink /etc/nginx/sites-enabled/default
</span></span></code></pre></div><h2 id=create-nginx-config><strong>Create <em><strong>NGINX</strong></em> Config</strong><a hidden class=anchor aria-hidden=true href=#create-nginx-config>#</a></h2><p>Create a config file in <strong>/etc/nginx/site-available</strong></p><blockquote><p><strong>Quick Note:</strong> use whichever text editor you want, I&rsquo;m using vim</p></blockquote><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo vim /etc/nginx/sites-available/blog.conf
</span></span></code></pre></div><div class=highlight><pre tabindex=0 class=chroma><code class=language-nginx data-lang=nginx><span class=line><span class=cl><span class=k>server</span> <span class=p>{</span>
</span></span><span class=line><span class=cl> <span class=kn>listen</span> <span class=mi>80</span><span class=p>;</span>
</span></span><span class=line><span class=cl> <span class=kn>server_name</span> <span class=s>blog.example.com</span><span class=p>;</span>
</span></span><span class=line><span class=cl> <span class=kn>location</span> <span class=s>/</span> <span class=p>{</span>
</span></span><span class=line><span class=cl> <span class=kn>proxy_pass</span> <span class=s>http://ip-of-server:port</span><span class=p>;</span>
</span></span><span class=line><span class=cl> <span class=p>}</span>
</span></span><span class=line><span class=cl><span class=p>}</span>
</span></span></code></pre></div><ul><li><strong>server_name</strong> is the domain name you want use this can include
sub-domains</li><li><strong>proxy_pass is the IP address of the web server</strong></li></ul><h2 id=enable-nginx-config><strong>Enable <em><strong>NGINX</strong></em> Config</strong><a hidden class=anchor aria-hidden=true href=#enable-nginx-config>#</a></h2><p>To activate a config file we need to link the file from the
<strong>sites-available</strong> folder to <strong>sites-enabled</strong>.</p><blockquote><p><strong>Pro Tip:</strong> make sure to use full paths when creating symlinks</p></blockquote><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo ln -s /etc/nginx/sites-available/blog.conf /etc/nginx/sites-enabled/blog.conf
</span></span></code></pre></div><p><strong>Check the config</strong>, this is an important step as it warns you of any errors before
reloading <em>NGINX</em></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo nginx -t
</span></span></code></pre></div><p>If the output looks simmiler to below then you&rsquo;re good to go !!</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
</span></span><span class=line><span class=cl>nginx: configuration file /etc/nginx/nginx.conf <span class=nb>test</span> is successful
</span></span></code></pre></div><p>Now <strong>restart the <em><strong>NGINX</strong></em> service</strong></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo systemctl restart nginx
</span></span></code></pre></div><p>you should now have a working reverse proxy !!</p><h1 id=setting-up-ssl><strong>Setting up SSL</strong><a hidden class=anchor aria-hidden=true href=#setting-up-ssl>#</a></h1><h2 id=prerequisites-1><strong>Prerequisites</strong><a hidden class=anchor aria-hidden=true href=#prerequisites-1>#</a></h2><ul><li>Make sure HTTP and HTTPS are port forwarded to the reverse proxy</li><li>Make sure <strong>server_name</strong> is set in the config file you created</li></ul><h2 id=installing-certbot><strong>Installing</strong> <em><strong>Certbot</strong></em><a hidden class=anchor aria-hidden=true href=#installing-certbot>#</a></h2><p><em>Certbot</em> is a tool that requests an SSL certificate and makes sure it
is renewed when needed.
<strong>Install</strong> <em><strong>Certbot</strong></em> as well as the <strong>python <em><strong>NGINX</strong></em> plug-in</strong></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo apt install certbot python3-certbot-nginx
</span></span></code></pre></div><blockquote><p><strong>Quick Note:</strong> double check firewall rules</p></blockquote><h2 id=request-ssl-certificate><strong>Request SSL Certificate</strong><a hidden class=anchor aria-hidden=true href=#request-ssl-certificate>#</a></h2><p>Now all we need to do is <strong>request the certificate</strong> !!</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo certbot --nginx -d blog.example.com
</span></span></code></pre></div><ul><li><strong>&ndash;nginx</strong> specifies we are using NGINX, this will update the config
file we created to allow the use of SSL</li><li><strong>-d</strong> is the domain name you want to use</li></ul><p>If this is the first time running <em>Certbot</em> you will be asked to enter
an email as well as agree to terms and services.</p><p>If the certificate request is successful you will be prompted with</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
</span></span><span class=line><span class=cl>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
</span></span><span class=line><span class=cl>1: No redirect - Make no further changes to the webserver configuration.
</span></span><span class=line><span class=cl>2: Redirect - Make all requests redirect to secure HTTPS access. Choose this <span class=k>for</span>
</span></span><span class=line><span class=cl>new sites, or <span class=k>if</span> you<span class=s1>&#39;re confident your site works on HTTPS. You can undo this
</span></span></span><span class=line><span class=cl><span class=s1>change by editing your web server&#39;</span>s configuration.
</span></span><span class=line><span class=cl>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
</span></span><span class=line><span class=cl>Select the appropriate number <span class=o>[</span>1-2<span class=o>]</span> <span class=k>then</span> <span class=o>[</span>enter<span class=o>]</span> <span class=o>(</span>press <span class=s1>&#39;c&#39;</span> to cancel<span class=o>)</span>:
</span></span></code></pre></div><p><strong>If you want all traffic to be SSL encrypted choose option 2</strong>
That&rsquo;s it we have SSL certificates installed. You will need a new
certificate for each different domain name or subdomain.</p><h2 id=verify-auto-renewal><strong>Verify Auto Renewal</strong><a hidden class=anchor aria-hidden=true href=#verify-auto-renewal>#</a></h2><p>All we need to do now is make sure that Certbot can automatically renew
certificates.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>sudo certbot renew --dry-run
</span></span></code></pre></div><p>If you see no errors then you are ready to go.</p><h1 id=conclusion><strong>Conclusion</strong><a hidden class=anchor aria-hidden=true href=#conclusion>#</a></h1><p>By following this you have hopefully managed to setup an <em>NGINX</em>
Reverse proxy to handle incoming HTTP/HTTPS requests as well as
configured automatically renewing SSL certificates.</p><p>This posts barely scratches the surface of what <em>NGINX</em> can do, I would
highly recommend reading more into this great piece of software !!</p><p>My reverse proxy handling non existent traffic</p><video autoplay loop muted playsinline aria-label=i-know-kung-fu style=display:block;margin-left:auto;margin-right:auto;width:50%;height:auto;padding:10px>
<source src=/webm/i-know-kung-fu.webm type=video/webm></video><p>Give it a few months and this blog will &mldr;</p><video autoplay loop muted playsinline aria-label='this is fine' style=display:block;margin-left:auto;margin-right:auto;width:50%;height:auto;padding:10px>
<source src=/webm/matrix-jump-fail.webm type=video/webm></video></div><footer class=post-footer><ul class=post-tags><li><a href=https://blog.ahmza.com/tags/homelab/>Homelab</a></li><li><a href=https://blog.ahmza.com/tags/networking/>Networking</a></li><li><a href=https://blog.ahmza.com/tags/nginx/>NGINX</a></li><li><a href=https://blog.ahmza.com/tags/reverseproxy/>ReverseProxy</a></li></ul></footer></article></main><footer class=footer><span>&copy; 2023 <a href=https://blog.ahmza.com>ahmza's ramblings</a></span>
<span>Powered by
<a href=https://gohugo.io/ rel="noopener noreferrer" target=_blank>Hugo</a> &
<a href=https://github.com/adityatelange/hugo-PaperMod/ rel=noopener target=_blank>PaperMod</a></span></footer><a href=#top aria-label="go to top" title="Go to Top (Alt + G)" class=top-link id=top-link accesskey=g><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6" fill="currentcolor"><path d="M12 6H0l6-6z"/></svg></a><script src=https://storage.ko-fi.com/cdn/scripts/overlay-widget.js></script><script>kofiWidgetOverlay.draw("ahmza",{type:"floating-chat","floating-chat.donateButton.text":"Tip","floating-chat.donateButton.background-color":"rgb(145, 70, 255)","floating-chat.donateButton.text-color":"#fff"})</script><script>let menu=document.getElementById("menu");menu&&(menu.scrollLeft=localStorage.getItem("menu-scroll-position"),menu.onscroll=function(){localStorage.setItem("menu-scroll-position",menu.scrollLeft)}),document.querySelectorAll('a[href^="#"]').forEach(e=>{e.addEventListener("click",function(e){e.preventDefault();var t=this.getAttribute("href").substr(1);window.matchMedia("(prefers-reduced-motion: reduce)").matches?document.querySelector(`[id='${decodeURIComponent(t)}']`).scrollIntoView():document.querySelector(`[id='${decodeURIComponent(t)}']`).scrollIntoView({behavior:"smooth"}),t==="top"?history.replaceState(null,null," "):history.pushState(null,null,`#${t}`)})})</script><script>var mybutton=document.getElementById("top-link");window.onscroll=function(){document.body.scrollTop>800||document.documentElement.scrollTop>800?(mybutton.style.visibility="visible",mybutton.style.opacity="1"):(mybutton.style.visibility="hidden",mybutton.style.opacity="0")}</script><script>document.getElementById("theme-toggle").addEventListener("click",()=>{document.body.className.includes("dark")?(document.body.classList.remove("dark"),localStorage.setItem("pref-theme","light")):(document.body.classList.add("dark"),localStorage.setItem("pref-theme","dark"))})</script><script>document.querySelectorAll("pre > code").forEach(e=>{const n=e.parentNode.parentNode,t=document.createElement("button");t.classList.add("copy-code"),t.innerHTML="copy";function s(){t.innerHTML="copied!",setTimeout(()=>{t.innerHTML="copy"},2e3)}t.addEventListener("click",t=>{if("clipboard"in navigator){navigator.clipboard.writeText(e.textContent),s();return}const n=document.createRange();n.selectNodeContents(e);const o=window.getSelection();o.removeAllRanges(),o.addRange(n);try{document.execCommand("copy"),s()}catch{}o.removeRange(n)}),n.classList.contains("highlight")?n.appendChild(t):n.parentNode.firstChild==n||(e.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName=="TABLE"?e.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(t):e.parentNode.appendChild(t))})</script></body></html>