Showing posts with label nginx. Show all posts
Showing posts with label nginx. Show all posts

November 06, 2025

Migrate from Nginx to Caddy for SSL auto-renewal in Amazon AWS EC2

 Dear friends,

Today, we will see a simple migration with less configuration of SSL auto-renewal.

I was using Nginx for SSL auto-renewal using certbot. Every 90 days, the renewal code should run, I made one more service it.

I have come across Caddy, which does an auto-renewal of SSL automatically with certbot. Reducing efforts and making the system smooth.

Follow the steps below

Stop and disable the Nginx

sudo systemctl stop nginx

sudo systemctl disable nginx

Install the Caddy

In EC2, if you are running Amazon Linux, then execute the following to install Caddy.

    sudo yum -y install yum-plugin-copr

    sudo yum -y copr enable @caddy/caddy epel-8-$(arch)

    sudo yum -y install caddy

Edit and configure the Caddyfile

Usually, it will be in the path /etc/caddy/Caddyfile

sudo vi /etc/caddy/Caddyfile

I have only one server that is running locally. So, my configuration is easy

domain_name {

    reverse_proxy localhost:port

}

You can configure more with your existing Nginx sites-enabled reference.

Happy SSLing.

If you like the blog or want to comment, kindly reach out to psrdotcom@gmail.com


June 11, 2022

Configure a API Backend Server with custom domain on Amazon Web Services (AWS) EC2 Ubuntu with NGINX and Certbot SSL

Hi all,

Build your own API backend server on AWS free-tier with SSL.

The below steps with reference links will provide detailed information of each step.

  1. AWS account - Free-tier
  2. Create EC2 Ubuntu
  3. Connect to Ubuntu from your local using SSH/Putty
  4. Install NodeJS
    1. Open terminal
    2. curl -fsSL http://deb.nodesource.com/setup_lts.x | sudo -E bash -
    3. sudo apt update
    4. sudo apt install nodejs //installs latest LTS nodejs
  5. Create a sample node server
  6. Install and configure node server process manager
    1. sudo npm install -g pm2@latest
    2. Navigate to nodejs server folder
    3. pm2 start <filename>
    4. pm2 startup systemd
    5. pm2 save
    6. pm2 list // List all the nodejs apps with status
    7. pm2 stop/restart/start app_name/id // Actions of nodejs servers
  7. Install Nginx
  8. Configure your domain DNS records to map to AWS EC2 public/elastic IP address
  9. Secure Nginx with SSL certs

Hope the above information is useful to set up the environment and play with your backend server.

Feel free to send your feedback and comments to psrdotcom@gmail.com


February 19, 2020

Nginx Load Balancing Configuration

Hi folks,

I am going to explain the process of load balancing the web application using Nginx

Pre-requisites


  • One machine with Nginx installation
  • Two machines with running the same web application

Test setup

All are Ubuntu server machines

  1. 10.10.1.1 - Load Balancer
  2. 10.10.1.2 - Node 1
  3. 10.10.1.3 - Node 2



Configuration

In the Nginx server machine (10.10.1.1) do the following load balancing configuration


  • Make sure you stop the nginx server if running

$ sudo service nginx stop

  • Edit the nginx.conf file 

$ sudo vi /etc/nginx/nginx.conf

  • Place the following sample content

http {
        upstream testsetup {
        server 10.10.1.2;
        server 10.10.1.3;
}
    server{
        listen 8090;
        server_name testsetup;
        location / {
            proxy_pass http://testsetup;
        }
    }
}

  • Start the Nginx server

$ sudo service nginx start

Load Balancing Test


  1. Access the 10.10.1.1:8090 in the web browser
  2. It will redirect to Node 1 (10.10.1.2)
  3. Refresh/Reload the page, the load balancer redirects to Node 2 (10.10.1.3)

Tip

To differentiate the web server, add a footer with different content (Static IP Address) in your index.html


Please send your comments and feedback to psrdotcom@gmail.com

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com