How To Set Nginx Reverse Proxy Server On Aws

Gupta Aditya
3 min readOct 3, 2021

Hey, guys hope you all are doing good in today's article we are going to see how can we set reverse proxy using Nginx now don't get confused if you don't know what reverse proxy is so don't worry will cover all things from basic.

First, let's understand what reverse proxy is and where can we use it. A reverse proxy is basically an intermediate point that takes requests from the client and gets information on behalf of a client from the backend application. A reverse proxy is generally used for security purposes suppose you have one backend application that directly connects from your database so you don't want to expose it to the public directly but wants the public to use it so in that case, we can reverse proxy so that only reverse proxy can connect to our application and user can connect to reverse proxy application.

I hope you understand what reverse proxy is and how can we use it now let's get started on how to set it up in AWS.

Here I am using aws ec2 instance with the ubuntu 18.04 image which first we install the Nginx server and then will install the certbot to generate an SSL certificate for our domain(Note this is optional if you want to access reverse proxy with HTTPS request).

sudo apt-get update
sudo apt-get install nginx
nginx -v
sudo apt update
sudo apt install certbot(optional)
systemctl stop nginx
sudo certbot certonly --standalone -d [your domain name](optional)
/etc/letsencrypt/live path for domain certificate(location for ssl cetificate where they get store)

After doing the above steps open /etc/Nginx file in your favorite editor and scroll down there you will see a block of HTTP make changes in that according to your need block will look like shown below.

Note if not wanting to use SSL then change the port from 443 to 80.

server {listen 443 ssl http2;listen [::]:443 ssl http2;server_name [domain name fqdn];location / {proxy_pass [“location where you want request to go and make action"];}ssl_certificate [ssl certificate location];ssl_certificate_key [ssl certificate];}

After setting up just run the below command to start their Nginx server

systemctl start nginx 

Guys, here we come to the end of this blog I hope you all like it and found it informative. If have any query feel free to reach me :).

Guys follow me for such amazing blogs and if have any review then please let me know I will keep those points in my mind next time while writing blogs. If want to read more such blog to know more about me here is my website link Please do not hesitate to keep 👏👏👏👏👏 for it (An Open Secret: You can clap up to 50 times for a post, and the best part is, it wouldn’t cost you anything), also feel free to share it across. This really means a lot to me.