Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement reverse proxy web server in Nginx

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to achieve reverse proxy web server in Nginx, the content is very detailed, interested friends can refer to, hope to be helpful to you.

A brief introduction to Nginx

Nginx is a powerful high-performance Web server and reverse proxy server with many excellent features:

1. Can connect with high concurrency

two。 Low memory consumption

3. Low cost

4. The configuration file is very simple

5. Support for Rewrite rewriting

6. Built-in health check function

7. Save bandwidth

8. High stability

9. Support for hot deployment

Comprehensive comparison of Nginx, Apache and Lighttpd

II. Overview of reverse proxy

Reverse proxy means that the proxy server accepts the connection request on the internet, then forwards the request to the server on the internal network, and returns the result obtained from the server to the client requesting the connection on the internet. At this time, the proxy server behaves as a reverse proxy server.

The reverse proxy is the server side, which is mainly used for the distributed deployment of the server cluster, and the reverse proxy hides the information of the server to the outside.

Let's configure the reverse proxy with Nginx.

Third, the experimental environment

This experiment simulates the client on the physical machine, configures the Nginx and Apache simulation server on a virtual machine, and realizes the reverse proxy through Nginx.

Client (win10): ip:192.168.5.120

Server (centos): ip:192.168.5.100

Nginx ports: 8010, 8020

Apache1 port: 666

Apache2 port: 888

Step 1 of the experiment. Deploy the test web page on the virtual machine Apache

Step 1: install Apache

Yum install httpd-y

Step 2: create two html files in the / var/www directory to access the data as two ports

The first one:

Second:

Step 3: modify the configuration file of Apache

Vi / etc/httpd/conf/httpd.conf

First, add the ports that need to be accessed:

Add a directory that accesses two ports at the end of the file:

Then wq saves and exits

Step 4: re-Apache service: systemctl restart httpd.service step 5: test in the browser:

The server-side configuration is complete

two。 Configure reverse proxy with Nginx step 1: install the Nginx service

Yum install nginx-y

Step 2: modify Nginx configuration file to configure reverse proxy

Vi/etc/nginx/nginx.conf

Add two server segments to the http section:

So port 8010 of Nginx proxies port 666 of Apache, port 8020 of Nginx proxies port 888 of Apache

Wq exit

Step 3: restart Nginx

Systemctl restart nginx.service

3. Two ports on which the host acts as the client access agent

4. Pay special attention to

In the above experiment, the virtual machine turned off selinux, otherwise an error would occur in nginx forwarding.

Turn off selinux (temporary): setsebool 0

Or modify the configuration file and restart: vi / etc/selinux/config

IV. Conclusion

Finally, the client accesses the proxy server, and the proxy server configures different policies to access different ports (which should actually be different servers) to achieve reverse proxy.

The role of reverse proxy:

1. To ensure the security of the intranet, the reverse proxy is usually used as the public network access address, and the Web server is the intranet.

two。 Cache, cache the response of the server in its own memory, reducing the pressure on the server.

3. Load balancing, through the reverse proxy server to optimize the load of the website.

On how to achieve reverse proxy web server in Nginx to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report