Set up reverse proxy server in Nginx
1. What is reverse proxy? What is the role of reverse proxy?
The Reverse Proxy method is to use a Proxy server to accept connection requests from the internet, and then forward the requests to the server on the internal network, return the result obtained from the server to the Client Requesting connection from the internet. The proxy server is displayed as a reverse proxy server.
When an external client attempts to access the content server, it will send it to the proxy server. The actual content is on the content server, which is protected by security inside the firewall. Therefore, the reverse proxy server also plays a role in security protection. In addition, it can also cache static content. When the static content changes, it notifies the reverse proxy server that the cache is invalid through the internal notification mechanism and needs to be reloaded. The reverse proxy server can also achieve load balancing.
Ii. Install Nginx
For Linux yumor rpminstallation, you can download the tar.gz package and decompress it to make the installation. The blogger is a Mac system, so the brew install nginx installation is complete. In addition, the proxy is an Application server. here we can use Tomcat, which is simple and convenient.
Iii. implementation scenarios
The tomcat port is the port 8080 of another machine, as shown in.
So what we need to achieve is to enter a port number of the local machine to access the tomcat content, then the local machine acts as a proxy server.
Iv. Configuration
First, go to the/usr/local/etc directory. We can see a nginx Directory, which contains basically nginx configuration files.
Find the nginx. conf file, open vi, and then find http {}, add an include/usr/local/etc/nginx/reverse-proxy.conf in;
Here it means to reference the configuration file of another Proxy service, exit vi, and create a new reverse-proxy.conf file under the same directory.
Upstream monitor_server {
Server 172.16.17.112: 8080;
}
Server
{
Listen 8900;
Server_name www.bkjia.net;
Location /{
Proxy_redirect off;
Proxy_set_header Host $ host;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Proxy_pass http: // monitor_server;
}
# Access_log logs/nagios. xxx123.tk _ access. log;
}
Follow the above configuration to modify the server_name. If you have a domain name, you can modify server_name. After the configuration is complete, run the nginx command to start it. The effect is as follows.
As you can see, enter localhost: 8900 to access the tomcat interface above 112.
V. Summary
Nginx is still widely used in network services. It is only a simple port proxy, and it does not take long for the bloggers to contact Nginx. If anything is wrong, please advise me, thank you.
You may also like the following Nginx articles. For more information, see:
Installation configuration https://www.bkjia.com/Linux/2017-04/142986.htm of Nginx server in CentOS 7
Install Nginx server on CentOS for virtual host and Domain Name Redirection https://www.bkjia.com/Linux/2017-04/142642.htm
CentOS 6.8 install LNMP environment (Linux + Nginx + MySQL + PHP) https://www.bkjia.com/Linux/2017-04/142880.htm
Install the PHP environment in Linux and configure Nginx to support php-fpm module https://www.bkjia.com/Linux/2017-05/144333.htm
SSL authentication and htpasswd authentication https://www.bkjia.com/Linux/2017-04/142478.htm for Nginx services
Enable encrypted secure Nginx Web Server https://www.bkjia.com/Linux/2017-07/145522.htm on Ubuntu 16.04
Installation and configuration of Nginx in Linux and detailed description of parameters https://www.bkjia.com/Linux/2017-05/143853.htm
Nginx log filtering using ngx_log_if does not record specific log https://www.bkjia.com/Linux/2014-07/104686.htm
CentOS 7.2 Nginx + PHP + MySQL + Memcache Cache Server Installation configuration https://www.bkjia.com/Linux/2017-03/142168.htm
Tomcat Load Balancing https://www.bkjia.com/Linux/2018-03/151223.htm through Nginx reverse proxy
Nginx details: click here
Nginx: click here
This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151418.htm