• 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)
    才能真正访问到

    250.cn
    location /proxy{
                proxy_pass http://251.cn;
            }
    
    http://250.cn/proxy/a  ->http://251.cn/proxy/a
    
    
    proxy_pass http://251.cn/;
    http://250.cn/proxy/news  -> http://251.cn//news
    
    proxy_pass http://251.cn/proxy;
    http://250.cn/proxy/news    ->http://251.cn/proxy/news
    
    proxy_pass http://251.cn/proxy/
    http://250.cn/proxy/news  ->http://251.cn/proxy//news
    http://250.cn/proxynews    ->http://251.cn/proxy/news
    
    proxy_pass 所在的location 后不能有正则表达式 
     "proxy_pass" cannot have URI part in location given by regular expression, 
    or inside named location, or inside "if" statement, or inside "limit_except" block in /usr/local/nginx/conf/nginx.conf:88 所在的块不能有rewrite

    待续.....

  • 相关阅读:
    【Java】久违了,Hello World!
    【Java】番外——BUG一词的由来
    【Java】数据类型、关键字、标识符
    【Java】一年后,重新开始学习Java!
    【Java】Path环境变量、Java_HOME
    【Java】Java环境安装
    反射
    修改metronome
    python 简单的动漫排名爬虫
    python 打包的 exe 程序自动更新
  • 原文地址:https://www.cnblogs.com/HKUI/p/9171268.html
Copyright © 2020-2023  润新知