摘要:一代理簡(jiǎn)介代理代理服務(wù)正向代理和反向代理區(qū)別在于代理的對(duì)象不一樣。
一、代理簡(jiǎn)介 1. 代理 2. Nginx代理服務(wù) 3. 正向代理和反向代理
區(qū)別在于代理的對(duì)象不一樣。
Syntax: proxy_pass URL; Default: — Context: location, if in location, limit_except
URL支持:
http:http://localhost:8000/uri/
https:https://192.168.1.111:8000/uri/
socket:http://unix:/tmp/backend.socket:/uri/
二、反向代理實(shí)例server { # 監(jiān)聽8080端口 listen 8080; location / { # 配置訪問(wèn)根目錄為 /vagrant/proxy root /vagrant/proxy; } }
server { # 監(jiān)聽80端口 listen 80; server_name localhost; location ~ /fx_proxy.html { # 設(shè)置反向代理,將訪問(wèn) /fx_proxy.html 的請(qǐng)求轉(zhuǎn)發(fā)到 http://127.0.0.1:8080 proxy_pass http://127.0.0.1:8080; } }
vim /vagrant/proxy/fx_proxy.html
反向代理 反向代理
[root~]# ss -tln State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:8080 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 *:22 *:* LISTEN 0 10 127.0.0.1:25 *:* LISTEN 0 128 :::22 :::*
http://127.0.0.1/fx_proxy.html可以正常訪問(wèn)
[root~]# curl http://127.0.0.1/fx_proxy.html反向代理 反向代理
http://127.0.0.1:8080/fx_proxy.html可以正常訪問(wèn)
[root~]# curl http://127.0.0.1:8080/fx_proxy.html三、正向代理實(shí)例反向代理 反向代理
正向代理須在有公網(wǎng)IP的正式的服務(wù)器上測(cè)試。
筆者遠(yuǎn)程服務(wù)器的IP地址為:39.106.178.166,測(cè)試用的域名為 zx_proxy.ws65535.top
server { # 監(jiān)聽80端口 listen 80; # 域名為 zx_proxy.ws65535.top; server_name zx_proxy.ws65535.top; location / { # $http_x_forwarded_for 可以記錄客戶端及所有中間代理的IP # 判斷客戶端IP地址是否是 39.106.178.166,不是則返回403 if ($http_x_forwarded_for !~* "^39.106.178.166") { return 403; } root /usr/share/nginx/html; index index.html; } }
server { # 代理服務(wù)監(jiān)聽的端口(注意,一定要看服務(wù)器供應(yīng)商控制臺(tái)的安全組是否開啟了該端口) listen 3389; # 配置DNS,223.5.5.5是阿里云的DNS resolver 223.5.5.5; # 正向代理配置 location / { proxy_pass http://$http_host$request_uri; } }
控制面板 -> 網(wǎng)絡(luò)和Internet -> 代理 -> 手動(dòng)設(shè)置代理
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/8083.html
摘要:一代理簡(jiǎn)介代理代理服務(wù)正向代理和反向代理區(qū)別在于代理的對(duì)象不一樣。 一、代理簡(jiǎn)介 1. 代理 showImg(https://segmentfault.com/img/remote/1460000015873425?w=556&h=248); 2. Nginx代理服務(wù) showImg(https://segmentfault.com/img/remote/146000001587342...
摘要:一代理簡(jiǎn)介代理代理服務(wù)正向代理和反向代理區(qū)別在于代理的對(duì)象不一樣。 一、代理簡(jiǎn)介 1. 代理 showImg(https://segmentfault.com/img/remote/1460000015873425?w=556&h=248); 2. Nginx代理服務(wù) showImg(https://segmentfault.com/img/remote/146000001587342...
摘要:無(wú)論這個(gè)連接是外部主動(dòng)建立的,還是內(nèi)部建立的。協(xié)議有表示層數(shù)據(jù)的表示安全壓縮。在整個(gè)發(fā)展過(guò)程中的所有思想和著重點(diǎn)都以一種稱為的文檔格式存在。 部署基礎(chǔ)知識(shí)url:協(xié)議://網(wǎng)站地址:端口(/)路徑地址?參數(shù)eg: http://www.baidu.com:80/abc/dd/ www.baidu.com找服務(wù)器 80端口:找服務(wù)器上提供服務(wù)的應(yīng)用 nginx uri:/ab...
摘要:無(wú)論這個(gè)連接是外部主動(dòng)建立的,還是內(nèi)部建立的。協(xié)議有表示層數(shù)據(jù)的表示安全壓縮。在整個(gè)發(fā)展過(guò)程中的所有思想和著重點(diǎn)都以一種稱為的文檔格式存在。 部署基礎(chǔ)知識(shí)url:協(xié)議://網(wǎng)站地址:端口(/)路徑地址?參數(shù)eg: http://www.baidu.com:80/abc/dd/ www.baidu.com找服務(wù)器 80端口:找服務(wù)器上提供服務(wù)的應(yīng)用 nginx uri:/ab...
閱讀 2243·2021-11-15 11:36
閱讀 1408·2021-10-14 09:42
閱讀 4239·2021-09-30 09:52
閱讀 1764·2021-09-24 10:24
閱讀 993·2021-09-02 09:56
閱讀 2715·2019-08-30 13:11
閱讀 3078·2019-08-30 13:06
閱讀 968·2019-08-30 12:56