Table of Contents
WHAT IS REVERSE AND FORWARD PROXY?
The forward proxy is what people call it as the simple proxy. The user sends the request to the proxy and it fetches data from the internet and lets the user have the access to the destination site. The forward proxy even allows you to send the request without having to bypass the firewall and its restrictions.
In simpler terms, the user request is sent to the forward proxy server, it’s then connected to the internet and then the destination site is displayed to the user.
While in reverse proxy the private networks are monitored. The reverse proxy can perform tasks such as authentication, load balancing and acts as a gateway for the servers. It makes sure that the incoming request won’t overload the server and if there are too many requests within a period from a single client. It raises a warning and is later blocked.
The main difference between the forward and backward proxy is that forward deals with displaying the content and works on the client-side. Whereas the reverse proxy works on the server-side or the backend and masks the location of IP of the requester. The client uses a forward proxy to put between itself and the server. In reverse proxy, the server puts between the client and itself.
WHY THE NEED FOR REVERSE PROXY?
Reverse proxy can connect and add a masking layer to the connection. You can access and run the website by linking the multiple ports to different modules or applications.
Reverse proxy allows you to dynamically change ports without manually typing them in the URL. The backend, frontend, and other services can be accessed without manually changing the port.
While developing an application on a local machine, the developer can access the build up through the https://localhost:port, the port can be changed and access different modules of the application. By using reverse proxy the manual labor can be automated.
GETTING STARTED!
docker ps -a

Step 1: Install the latest version of Docker
For this you can follow this article How to install Docker.Step 2: Installing Nginx
It is up to you if you want to use apache or nginx. In this article, the server is powered by nginx and we will consider it throughout the article. Execute the following command to install.sudo apt-get install nginx

If you are using windows you can download the package and run the exe from the following site http://nginx.org/en/docs/windows.html.
Step 3: Install a Docker image
To install MariaDB and WordPress in the docker, run the following command.
docker run -e MYSQL_ROOT_PASSWORD='password' -e MYSQL_DATABASE=wordpress --name mariadb -d mariadb:latest
Let’s break down the command and see what it’s doing. The docker run command will activate and run the container with the password provided for the database. In the ‘password’ you will exchange it with your MariaDB password.
The MySQL database is setting the configuration to the WordPress linkup and the –name flag sets the name to “mariadb”. –e sets the environment variable in which the container will run. –d flags command the container to be active in the background process. MariaDB: latest installs the latest version of the MariaDB, you can also install the specific version if you want by entering the version like mariabd: 5.8.
You can run the following command to find the details of the container.

server {
# Just the server name
server_name wordpress.your-domain.sh www.wordpress. your-domain.sh;
# Logs
access_log /var/log/nginx/wordpress. your-domain.sh/logs/access.log;
error_log /var/log/nginx/wordpress.your-domain.sh/logs/error.log;
location / {
proxy_pass http://localhost:9009;
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;
proxy_set_header X-Forwarded-SSL on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}

docker run -e WORDPRESS_CONFIG_EXTRA="define('WP_HOME','https://wordpress.your-domain.sh/'); define('WP_SITEURL','https://wordpress. your-domain.sh/');" -e WORDPRESS_DB_PASSWORD='YOUR PASSWORD ' --name wordpress --link mariadb:mysql -p 9009:80 -d wordpress
sudo service nginx restart
docker run --name wordpress1 -p 9009:80 -d wordpress

Conclusion
This article covers the nginx reverse proxy and highlights its benefits form which the one that stands out the most is the easy linkup between the URL and the corresponding ports. By configuring the settings of the nginx files and defining the routes creates a masking layer between the server and the client-side.