Set Up a Secure Site with Nginx Reverse Proxy and Let’s Encrypt – Ubuntu

Nginx is a powerful web server and reverse proxy tool that enhances the performance, scalability, and security of web applications. A reverse proxy acts as an intermediary between clients and backend servers, forwarding client requests to the appropriate server while managing load balancing, caching, and SSL termination.

This guide walks you through the steps to set up an Nginx reverse proxy on an Ubuntu server, including configuring domain-based routing, testing your configuration, and securing your connection with SSL.

Nginx

Install nginx

Check if the service is active and running

Create the configuration file for reverse proxy. Make sure to replace <domain_name> with your domain name at all places

Change <port> to your application’s port and save

Next to enable this configuration file create a symbolic link to the sites-enabled directory from sites-available directory

Now run the below command to test your configuration file for any errors

You should see the below output if all configurations are correct

Now restart nginx service to apply changes

Let’s Encrypt

Install certbot with nginx plugin

Run the below command to use nginx plugin with certbot

Then you’ll be asked for an email address for renewal purposes

Enter y to agree to their Terms of Services

Next you can either select y or n to share your email with Electronic Frontier Foundation

Now you’ll see the list of domain names, select the numbers of the domain names which you need to activate HTTPS for and Enter

And then it’ll activate and issue Lets Encrypt certificate for your domains

If everything went as it should be, you must be able to access your domain with https://<domain_name>

Umar Arafath

Hey there! I'm Umar Arafath, the face behind unofficialmentor, a passionate Software Engineering undergraduate diving into the IT industry. Even though my formal title may be a student, my heart lies in the field of DevOps. I share my daily learning adventures in this blog so it'll help me remember stuff. It's a win-win end of the day, I reinforce my knowledge, and you learn something new. Please be kind enough to leave a comment! Your feedback fuels my growth. Away from the desk, catch me on the cricket field or badminton court, polishing my physique. I'm also a motorbike enthusiast, who finds riding as a healing spell for my inner peace.

Leave a Reply

Your email address will not be published. Required fields are marked *