Article Directory
1 Introduction
nginx
It can 反向代理
be used not only to do it , but also to do 正向代理
( 透明代理
, 代理上网
),
Here you can browse the nginx reverse proxy
2. Reverse proxy
External device through 网关
access to content on the back of the gateway server, 网关
played a 反向代理
feature we usually accessed remotely through a browser web服务器
mostly are implemented.
3. Forward proxy
It is the reverse of the above process. As we usually say 上网代理
, users in the local area network access external networks through the gateway as a proxy.
4. Comparative analysis of forward proxy and reverse proxy
Both of them have three common roles:
请求者
代理者
实际目标
If cross-domain problems are encountered during local development, we do proxy forwarding:
/api/items
=> http://localhost:3000/api/items
(Forward) =>http://localhost:7777/api/items
This kind of forwarding is called 正向代理
=> 请求者&代理者
in the same domain ( 被服务端
) and the target is on another server ( 服务端
)
请求者
Usually browser
代理者
http://localhost:3000
实际目标
http://localhost:7777
Reverse proxy
请求者
Is a domain ( 被服务端
) 代理&目标
is another group ( 服务端
)
Most of the actual local development belongs to 正向代理
. If the code is compiled and dropped on the server, this time will inevitably involve cross-domain. If the front-end code is server1
accessed, and the back-end code is server2
accessed, the browser and them are separated, this time is the 反向代理
mode .
Usually develop when the browser is also the same broker on one server, are generally developed 正向代理
, and after the release, the browser will not be together, that is 反向代理
the.
5. Nginx proxy Internet access
nginx
It can also realize the function of proxy surfing, the configuration is as follows:
user www;
worker_processes 1;
error_log /var/log/nginx/error.log debug;
events {
use epoll;
worker_connections 1024;
}
http {
resolver 8.8.8.8;
server {
listen 8088;
location / {
proxy_pass http://$http_host$request_uri;
}
}
}
nginx
There are three key points to pay attention to to realize proxy Internet access, and the rest of the configuration is the nginx
same as ordinary
1. Increase dns
analysisresolver
2. Increase the no server_name
nameserver
3. proxy_pass
Instructions
6. Implementation steps
1. Fill in the following configuration to the http scope of your configuration file
resolver 8.8.8.8;
server {
listen 8088;
location / {
proxy_pass http://$http_host$request_uri;
}
}
2. Restart nginx to make the configuration file effective
nginx -s reload
3. Set up ie proxy
4. You can use the proxy to go online
You can visit http://ip.quancha.cn to check whether the proxy is effective. After
using the nginx
proxy to go online
Before using nginx proxy to go online
(To be added later)