How to Configure Nginx Reverse Proxy


How to Configure Nginx Reverse Proxy. Reverse Proxy on the Linux operating system acts as a link between the host (client) and server. Reverse proxy carries client requests and channels them to another server. Finally, delivering the server response to the client, as if it emerged from the proxy server itself. In this tutorial, we will show you what Nginx reverse proxy is and how to configure it on your VPS!

Client and server always exchange information in order to work efficiently. Commonly the reverse proxy is used by web servers. Reverse proxy or gateway will look like a web server in general in front of clients where no special configuration is needed. The client will make the request as usual while the proxy determines where the information will deliver the final output to the client.

Nginx reverse proxy has many uses. Reverse proxy is an open source that is widely used on the internet.

How to Configure Nginx Reverse Proxy – General Solusindo


Advantages of Using Nginx Reverse Proxy



Let's review why this tool is so popular:
  • This tool is very easy to implement and provides high-end security for its users to avoid attacks on web servers such as DDoS and DoS
  • Nginx Reverse proxy can balance load on some back-end servers and provide caching for slow back-end servers
  • Nginx does not require a new process configuration for each web request from the client. In fact, the default configuration is used to comprise one work process per CPU
  • This tool can act as a reverse proxy server for various protocols such as HTTP, HTTPS, TCP, UDP, SMTP, IMAP, and POP3
  • Can control more than 10000 connections with low memory footprint. Nginx can operate multiple web servers via one IP address and deliver each request to the right server via LAN
  • Nginx is one of the best web servers to improve static content performance. Plus, it can also be useful for caching content and SSL encryption to reduce web server load
  • This tool will be very helpful when optimizing content by compressing the content to speed up loading time
  • Nginx can do random experiments or A / B tests without placing JacaScript code on the page.

All that has been mentioned is only the tip of the iceberg! Of course you should try it yourself to find out the other advantages of Nginx Reverse Proxy.

How to Configure Nginx Reverse Proxy

Urgent:
First - You need to log in to the VPS server using SSH. Second - as explained earlier, you must have an Apache web server installed and configured in order to run the Nginx Reverse Proxy installation.

Now, configure Nginx in front of the Apache web server. We choose Apache servers because Apache is very good at controlling dynamic content.

So, static content will be on Nginx, while dynamic is on Apache because therein lies the advantage of Apache. This will improve server performance by optimizing content delivery based on handling criteria.

Next, we will define the IP address of the Nginx Proxy Server as 192.x.x.1 and the Apache back-end server as 192.x.x.2. After setting up Apache, we can move on to the following steps:

1. Install Nginx

The apt command will be used in this step, the following is the command:

sudo apt-get update

sudo apt-get install nginx

2. Disable the Default Virtual House

After nginx is installed on your device, enter the following command to disable the virtual host:

sudo unlink / etc / nginx / sites-enabled / default

3. Install Nginx Reverse Proxy

After disabling the virtual host, you need to create a file called reverse-proxy.conf in the etc / nginx / sites-available directory to store the reverse proxy information.

For this, you must first access the directory using the cd command:

cd etc / nginx / sites-available /

Then you can create files using the vi editor:

vi reverse-proxy.conf

Copy the following string into the file that was created:

server {
     listen 80;
     location / {
         proxy_pass http: //192.x.x.2;
     }
}

In the above command, a pretty important point is the pass proxy allows requests that come through the reverse Nginx proxy to forward to 192.x.x.2: 80, which is the Apache remote socket. As such, the two web servers - Nginx and Apache share content.

When finished, simply save the file and exit the vi editor. You can do this by entering: wq.

To forward information to another server, you can use nginx_http_proxy_module in the terminal.

Now, activate the directive by linking it to / sites-enabled / using the following command:

sudo ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/reverse-proxy.conf

4. Test Nginx and Nginx Reverse Proxy

You have arrived at the last step of this tutorial, namely running the Nginx configuration test and restarting Nginx to test its performance. Enter the command below in the Linux terminal to verify Nginx functionality.

nginx configtest service

nginx service restart

You need to remember that if the test that you run fails, it may be because Apache is not setup correctly,

Conclusion

There are many benefits of Nginx reverse proxy for your device that has a Linux operating system. Reverse proxy can increase performance effectively while increasing security against malware. Configuring a Nginx reverse proxy is easy to do on a Linux terminal. Although there are various ways to install and configure it, the tutorial above is not complicated and straightforward. Good luck!

Network Installation Services

CCTV Camera Installation Services

Fiber Optic Splicing Service

Server Installation Services