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。 





      

  • 相关阅读:
    yii修改密码 弹出修改成功提示(八)
    yii模型规则的简单使用以及开启前端的验证(七)
    利用ab测试并发可靠么
    yii数据库链接(六)
    初始化collectionViewCell
    监听事件
    ControllerEvent
    代码构建视图
    DeveloperAppleHelp
    Xcode 小技巧
  • 原文地址:https://www.cnblogs.com/ahuo/p/9516918.html
Copyright © 2011-2022 走看看