Saturday, March 14, 2020

Configuring an Nginx Server as a Reverse Proxy for an Apache Server

For this example I created and configured an Ubuntu virtual machine in the cloud. I next installed Nginx and Apache servers on the machine. Finally I configured Nginx as a reverse proxy for Apache. The purpose of this is that different servers are more efficient individually at delivering specific types of content. Specifically Nginx is better at serving static content and Apache is better at serving the backend data as is found in SQL servers.

The process has quite a few steps. Once I had my Ubuntu server in the cloud I then proceeded to update all the software and install Nginx. A quick curl command of curl -I localhost shows that my localhost is now Nginx. So at this point I was now able to proceed to the rest of the configuring.


Nginx is now up and running as my localhost.

Next I installed an Apache server on the virtual machine which will be serving the backend content from a database. Since Nginx is running on port 80 and Apache wanted to start on port 80 as well, I went into the configuration file for the Apache ports and changed the listening port to 8080 and specifically for ssl_module and mod_gnutls.c I put the listening port to 8443.

Port configuration file for Apache.


After restarting the Apache server and getting its status I can see the following message that lets me know a few things about the Apache server including its status, ID and tasks. Here I am most concerned with the system running successfully using my configuration file I just modified.

Apache server is up and running.


Next I want to confirm the web page status from the terminal. I sent a quick curl command to localhost:8080 and can now confirm with a 200 success message that Apache is the server on port 8080 for the localhost of the Ubuntu virtual machine.

Apache is now live and serving content.

Next I need to configure Nginx as a proxy. Here is the configuration needed for the Nginx server.

Now I restart the Nginx server and when I navigate to the URL of my cloud server I get an Apache page. Upon further inspection of the Network you can see that the server is nginx/1.14.0 (Ubuntu). 
  1. Server:
    nginx/1.14.0 (Ubuntu)


Nginx as a reverse proxy for Apache.
So now I have successfully configured Nginx as a reverse proxy for Apache and can build more content but am ready to scale and run at maximum efficiency for delivering static HTML content and SQL data at the same time.


No comments:

Post a Comment

Automated Exploitation of a Bluetooth vulnerability that leads to 0-click code execution

This blog post covers an interesting vulnerability that was just discovered earlier this year and an open source free tool that was created ...