zoukankan      html  css  js  c++  java
  • Nginx *

    upstream test {
    server  127.0.0.1:8080;
    }
    
    
    upstream v2.c.y.com {
    server  1.159.227.3;
    }
    
    upstream auth.y.com {
    server  1.159.227.3;
    }
    
        server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
    
    
            location /api/userCredit/calculateLocalPayment {
                proxy_pass http://test;
    
                root   html;
                index  index.html index.htm;
            }
            location /api/userCredit/getBalance {
                proxy_pass http://test;
    
                root   html;
                index  index.html index.htm;
            }
            
            location /api/userCredit/pay {
                proxy_pass http://test;
    
                root   html;
                index  index.html index.htm;
            }
            location / {
                proxy_pass http://v2.clientapi.y.com;
    
                root   html;
                index  index.html index.htm;
            }
    
    location /token {
                proxy_pass http://auth.y.com;
    
                root   html;
                index  index.html index.htm;
            }

    返回json
    location ~ ^/get_json {
        default_type application/json;
        return 200 '{"status":"success","result":"nginx json"}';
    }
    
    

    匹配模式及顺序

      location = /uri    =开头表示精确匹配,只有完全匹配上才能生效。

      location ^~ /uri   ^~ 开头对URL路径进行前缀匹配,并且在正则之前。

      location ~ pattern  ~开头表示区分大小写的正则匹配。

      location ~* pattern  ~*开头表示不区分大小写的正则匹配。

      location /uri     不带任何修饰符,也表示前缀匹配,但是在正则匹配之后。

      location /      通用匹配,任何未匹配到其它location的请求都会匹配到,相当于switch中的default。 





      

  • 相关阅读:
    httpclient5:信任所有证书,调用公众号接口
    驾驶技能考试系统:常见故障原因分析及排除
    C#:Combox实现key,value
    C#:密码框的两种方式
    C#:动态添加或删除控件,并根据控件名称获得控件
    微服务设计模式
    微服务设计模式
    微服务设计模式
    微服务设计模式
    微服务设计模式
  • 原文地址:https://www.cnblogs.com/ahuo/p/9516918.html
Copyright © 2011-2022 走看看