Installing NGINX on Amazon Linux is straightforward, with only one command:
sudo yum install nginx
Once NGINX is ready, let's install the SSL certificate with Let's Encrypt (https://letsencrypt.org). Hats off to the Let's Encrypt team! Before installing the SSL certificate, we need to make sure the taskagile.com domain points to the server. We will use Certbot (https://github.com/certbot/certbot) to automate the generated certificate by using the following command:
sudo yum install -y certbot python2-certbot-nginx
Once Certbot is installed, start the generating process with the following command and follow the instructions to finish the certificate generation:
sudo certbot
When you see a success message similar to the following, it means the SSL certificate has been installed successfully, and Certbot has updated NGINX's /etc/nginx/nginx.conf configuration file to enable HTTPS automatically:
Congratulations! You have successfully enabled https://taskagile.com
Now, we need to do a reverse proxy, by asking NGINX to forward requests to our application at port 8080. Open /etc/nginx/nginx.conf, and update the location / subsection of the http section as follows:
...
http {
...
server {
server_name taskagile.com;
...
location / {
proxy_read_timeout 1000;
proxy_send_timeout 1000;
proxy_pass http://127.0.0.1:8080;
proxy_buffering on;
proxy_connect_timeout 15;
proxy_intercept_errors on;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
...
}
}
...
And with that, we've completed the preparation of the server.