当前位置:网站首页>[v. reverse proxy and related configurations]
[v. reverse proxy and related configurations]
2022-06-09 15:23:00 【Little silly bird_ coding】
List of articles
Reverse proxy and its related configuration
1. Reverse proxy
The proxy provided by the server is a reverse proxy
principle : When a user requests resources from the server , He will First in Nginx, from Nginx Then request resources from the server , When you get the resources , The server will first send resources to Nginx On , Then from Nginx Send to the user , here Nginx It's the reverse proxy server .

2. Forward agency
The proxy provided by the user is a forward proxy (socket agent ,http Agent etc. )

3. gateway
Forward proxy 、 The reverse proxy server is essentially the same as the gateway .
The gateway is the gateway to access the network , For example, a router in a home is equivalent to a gateway , I'm using my home phone , Tablet, etc , Accessing resources will be called to the gateway , In transmission out . A popular gateway is equivalent to the gate of a school , You want to go out , You have to go through the gate .
Gateway features : transit .
User access to resources , All need to enter the gateway , When the request is sent to the server through the gateway , The server will send the information , To the gateway , Finally, it is passed to the user .
problem : When a user requests more , When the flow is high , If the maximum bandwidth of the gateway is not large , There will be a blockage .
resolvent : You can only increase the bandwidth of the proxy server .
4. Nginx The disadvantages of reverse proxy
because nginx Proxy bandwidth , Determines the network bandwidth of the user cluster , At higher io operation ,nginx Acting as a reverse agent , The effect is not obvious .
Solution : When a user requests the server , Must go through nginx, But when the server returns data , Call the user directly , Not after nginx(DR Model )

5. Reverse agent configuration
1. Jump to the extranet website
be used proxy_pass Keyword settings
proxy_pass There are two configuration methods
It can be the address of the agent , This address can be a host or a web address
You can configure it into a group of servers ( The following is a server )

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://www.baidu.com; // Only this place has changed
#root html;
#index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Running results :

2. Jump to the local server
Set up two virtual hosts : Here is a ip:192.168.56.136, The other is 192.168.56.137

I use the bridging method , direct nat Methods and host only methods have been tried , But both virtual machines ping no .
Be careful :
When the agent arrives at the website , Virtual machine requirements Ping Only through the Internet can
When proxy the local server , Two virtual machines need ping A generalist can .( Which server do you want to proxy , You just need to be with someone ping through )
Modify the network configuration command
vi /etc/sysconfig/network-scripts/ifcfg-ens33
CentOS7 Configuration situation :(ip:192.168.56.136)
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="DHCP"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="b73ab354-05d7-4492-87df-d537a32120bd"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.56.136
NETMASK=255.255.255.0
GETWAY=192.168.56.2
DNS1=8.8.8.8
Nginx Configuration situation :(ip:192.168.56.137)
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="DHCP"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="b73ab354-05d7-4492-87df-d537a32120bd"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.56.137
NETMASK=255.255.255.0
GETWAY=192.168.56.2
DNS=8.8.8.8
To configure centos7 Medium nginx.conf file The file has only been modified in one place
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://192.168.56.137; // This is the only place that has changed
#root html;
#index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
To configure nginx2 Medium nginx.conf file File not modified , Keep the default
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
To distinguish between the default root Under the html, take 192.168.56.137 Below html Change the document to


<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body>
<body style="background-color: pink">
<h1>192.168.56.137</h1>
</body>
</html>
Running results :( By entering 192.168.56.136, Due to the proxy_pass He will jump to 192.168.56.137, Then show 137 Below html file )


At present, it is only a proxy server , You can proxy to multiple servers
边栏推荐
- 期货网上开户安全吗?期货妙手机开户吗?
- Brand renewal, product innovation, marketing innovation, Dongfeng Peugeot's upward road
- Global backbone network was interrupted for 4 hours: Google cloud, AWS, azure, etc. were affected
- 【实战】Redis Cluster(上)-环境搭建
- InfoQ 极客传媒 15 周年庆征文|云原生时代微服务架构设计实践
- Design of cache address mapping and transformation and associated directory table in cache memory
- Hongmeng porting i.mx6ull (VIII) adding a board
- [Typecho blog Xiaobai building tutorial] you are only one step away from having your own blog
- MySQL 8.0.29 安装配置方法图文教程(windows zip版)
- AE script - grid reference line golden section line generation tool guidesup! 2.2 active version
猜你喜欢
随机推荐
QT MSVC compiler Chinese problem solving, Chinese garbled and unable to compile normally
自如涨价,会逼退年轻人吗?
JS实现复制内容到剪贴板的方法
软件测试职业发展方向,6年老测试带你走出迷茫...
【三、ServerName 匹配规则】
分布式限流之基于Sentinel实现的限流漫谈(一)-概述
Redis实现登录注册的示例代码
格林大华期货开户安全吗?在哪里可以开户?
134. 加油站
利用Redis进行数据缓存的项目实践
华为十大发明公布:高效加法网络、多目标博弈智能驾驶获奖
Performance monster on arm64: installation and performance test of API gateway Apache APIs IX on AWS graviton3
Hongmeng transplants the compiling system of i.mx6ull (VII) liteos-a
技术干货 | Linkis实践:新引擎实现流程解析
【云小课】应用平台第43课 云小课带您快速入门多云高可用服务
[云原生]Kubernetes可视化界面WEBUI Kubernetes Dashboard
InfoQ 极客传媒 15 周年庆征文|云原生时代微服务架构设计实践
Gaussdb (DWS) functions and supporting tools [Gauss is not a mathematician this time]
Geoffrey Hinton's latest interview: within five years, we will crack the brain's operating mechanism, but not through back propagation
Hongmeng transplantation i.mx6ull (V) overview of transplantation








