Server Management 2025-01-30 14:21:47
Khalequzzaman

Published By

Khalequzzaman

Nginx (Reverse Proxy) SSL Setup with Certbot

This guide outlines the steps to install Nginx, configure it as a reverse proxy, enable SSL with Certbot, and ensure automatic SSL renewal.
1. Install Nginx
To install Nginx, run the following command:
sudo apt install nginx -y
2. Create Nginx Server Block
Next, create a new Nginx server block configuration. Edit the file at `/etc/nginx/sites-available/openwebui` and add the following content:
server {
    listen 80;
    server_name caldon.sysninja.net;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
Replace `caldon.sysninja.net` with your actual domain name.
3. Enable Server Block
To enable the newly created server block, create a symbolic link in the `sites-enabled` directory:
sudo ln -s /etc/nginx/sites-available/openwebui /etc/nginx/sites-enabled/
4. Test and Restart Nginx
Test the Nginx configuration to ensure there are no syntax errors and restart Nginx:
sudo nginx -t
sudo systemctl restart nginx
5. Install Certbot
Now, install Certbot along with the Nginx plugin to obtain SSL certificates:
sudo apt install certbot python3-certbot-nginx -y
6. Obtain SSL Certificate
To automatically configure SSL for your domain, run:
sudo certbot --nginx -d caldon.sysninja.net
This will configure Nginx to use SSL with Certbot for your domain.
7. Verify SSL
Once the SSL certificate is installed, verify it by visiting your website: https://caldon.sysninja.net Your site should load with HTTPS, indicating the SSL certificate is active.
8. Test SSL Renewal
To ensure that your SSL certificate renews automatically, run a dry run:
sudo certbot renew --dry-run
If the dry run succeeds, Certbot will automatically renew your SSL certificate before it expires. With these steps completed, your Nginx server is now set up with SSL, ensuring secure connections to your website.

Comments

No approved comments yet.

Add Comment