nginx代理

正向代理:代理对象是客服端
反向代理:代理对象是服务端
区别所代理的对象不一样

#配置语法
Syntax: proxy_pass URL;
Default:-
ContextLlocation,if in location,limit_except
#配置
#192.168.0.250 (代理服务器)

resolver 8.8.8.8;
location / {
    #default_type text/html;
    #return 200 http_host:$http_host<br>request_uri:$request_uri;
    proxy_set_header X-Forwarded-For 250.cn;
    proxy_pass http://$http_host$request_uri;
}

#192.168.0.251
location / {
    default_type text/html;
    if ($http_x_forwarded_for != "250.cn" ){
        return 200 http_x_forwarded_for:$http_x_forwarded_for;
     }
    index  index.html index.htm;
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
    }

本地访问
http://251.cn/
客户端设置250的代理(chrome可通过SwitchySharp)
才能真正访问到

猜你喜欢

转载自www.cnblogs.com/HKUI/p/9171268.html