• nginx proxy


    listen 80;
    server_name localhost;
    
    # 访问"localhost"的全部请求会被转发到"localhost:81"
    # localhost => localhost:81
    # localhost/a/ => localhost:81/a/
    # localhost/b/ => localhost:81/b/
    location / {
     proxy_pass http://localhost:81;
    }
    
    # 访问"localhost"的全部请求会被转发到"localhost:81/a/"
    # localhost => localhost:81/a/
    # localhost/a/ => localhost:81/a/a/
    # localhost/b/ => localhost:81/a/b/
    location / {
     proxy_pass http://localhost:81/a/;
    }
    
    
    # 访问"localhost/c/"的全部请求会被转发到"localhost:81/a/"
    # localhost => 不会转发
    # localhost/c/ => localhost:81/a/
    # localhost/c/aa/ => localhost:81/a/aa/
    location /c/ {
     proxy_pass http://localhost:81/a/;
    }
    
    # 访问"localhost/api/"的全部请求会被转发到"localhost:81"
    # localhost => 不会转发
    # localhost/api/ => localhost:81
    # localhost/api/a/ => localhost:81/a/
    # localhost/api/b/ => localhost:81/b/
    location /api/ {
      # rewrite 的作用是修改URI
      rewrite ^/api(/.*)$ $1 break;
      proxy_pass http://localhost:81;
    }
    
    # http://localhost/api/ => http://127.0.0.1:81/
    # http://localhost/api/a/ => http://127.0.0.1:81/a/
    # http://localhost/api/b/ => http://127.0.0.1:81/b/
    # http://localhost/api/?path=/a => http://127.0.0.1:81/a
    # http://localhost/api/?path=/b => http://127.0.0.1:81/b
    location /api/ {
      if ($arg_path = '') {
        rewrite ^/api(/.*) $1 break;
        set $arg_path $1;
      }
      proxy_pass http://127.0.0.1:81$arg_path;
    }
    
  • 相关阅读:
    1347: Last Digit (周期函数)
    1363: Count 101 (经典数位dp)
    1360: Good Serial Inc.(不知道是什么类型的题)
    C#winForm调用WebService的远程接口
    Web Service 的创建简单编码、发布和部署
    极致精简的webservice集成例子
    SVN使用教程总结
    C# int.Parse()与int.TryParse()
    C# 函数1 (函数的定义)
    C#中的委托和事件
  • 原文地址:https://www.cnblogs.com/ajanuw/p/14305212.html
Copyright © 2020-2023  润新知