Setup Nginx Reverse Proxy For Mirth in AWS
The Idea of this blog is to setup an reverse-proxy for Mirth using the Nginx application in the Amazon EC2 instance. Let me first give an easy understanding on what is reverse proxy.
Basically, the reverse proxy is a way of masking the application url with a different one. In the picture above, you can see that the client will never know to which server they are sending the data to. That is the goodness of making a reverse-proxy.
So, the pre-requisite to do this is, we need to have a Ec2 instance where we have mirth/any application configured and running already. But, exposing the address directly to the public is very risky. It is always preferred to mask the url of the application with something else. For this purpose we will use Nginx and create a Reverse-Proxy for the Mirth URL.
The other major advantage of using the reverse-proxy is that we can leverage the Ec2 instance running the Nginx as a load balancer as well. Although there is another load balancing feature exist in the AWS, this can come pretty handy.
Step 1: Get an amazon AMI EC2 instance to install Nginx in it.
Step 2: Install Nginx – use this command sudo amazon-linux-extras install -y nginx1.12. End of installation will show like this
Step 3: Start the service of Nginx using this command sudo service nginx start, Note in some of the linux instances sudo service nginx on will work.
Step 4: Now test if the Nginx works in the browser. For that open the security group of the ec2 instance and open the http port 80 and https port 443.
Step 5: Put the public ip v4 in browser
Step 6: Navigate to cd /etc/nginx/nginx.conf use Vim editor and do sudo vim nginx.conf.
Step 7: Add the code in the place of location in the conf file as shown below
Step 8: Reload the nginx config file using the command sudo nginx-s reload
Now, the proxy is setup. The mirth will now expose its proxy address than the original one.