• nginx proxy_pass指令 uri以 "/" 结尾和不以 "/" 结尾的区别


    当location uri为正则匹配(即 location ~ | ~* uri)时,proxy_pass中的url末尾是不允许有 "/" 的

    一、proxy_pass指令 uri 不以 "/" 结尾

    location /test {
       proxy_pass http://192.168.99.10:99;
    }
    
    访问地址:本机IP:port/test
    实际地址:http://192.168.99.10:99/test
    test是一个普通文件且在192.168.99.10主机上必须存在
    
    
    location /test/ {
       proxy_pass http://192.168.99.10:99;
    }
    
    访问地址:本机IP:port/test/xxx
    实际地址:http://192.168.99.10:99/test/xxx
    test是一个目录且/test/xxx在192.168.99.10主机上必须存在
    xxx为任意普通文件
    
    
    location /test {
       proxy_pass http://192.168.99.10:99/server;
    }
    访问地址:本机IP:port/test
    实际地址:http://192.168.99.10:99/server/test
    test是一个普通文件且/server/test在192.168.99.10主机上必须存在
    
    location /test/ {
       proxy_pass http://192.168.99.10:99/server;
    }
    访问地址:本机IP:port/test/xxx
    实际地址:http://192.168.99.10:99/server/test/xxx
    test是一个目录且/server/test/xxx在192.168.99.10主机上必须存在
    xxx为任意普通文件

    二、proxy_pass指令 uri 以 "/" 结尾

    location /test {
       proxy_pass http://192.168.99.10:99/;
    }
    
    访问地址:本机IP:port/test
    实际地址:http://192.168.99.10:99/index.html
    test在本机和192.168.99.10不一定存在
    
    location /test/ {
       proxy_pass http://192.168.99.10:99/;
    }
    
    访问地址:本机IP:port/test/
    实际地址:http://192.168.99.10:99/index.html
    test在本机和192.168.99.10不一定存在
    
    
    location /test {
       proxy_pass http://192.168.99.10:99/server/;
    }
    
    访问地址:本机IP:port/test
    实际地址:http://192.168.99.10:99/server/index.html
    test在本机和192.168.99.10不一定存在,但是server/在192.168.99.10一定存在
    
    location /test/ {
       proxy_pass http://192.168.99.10:99/server/;
    }
    
    访问地址:本机IP:port/test/
    实际地址:http://192.168.99.10:99/server/index.html
    test在本机和192.168.99.10不一定存在,但是server/在192.168.99.10一定存在
  • 相关阅读:
    java核心技术记录之集合
    Set的非重复判断是根据什么判断的
    struts2-2.3.4.1的struts-default.xml源码
    纯代码搭建项目框架
    初始化项目
    项目部署
    使用estimatedRowHeight的优缺点
    懒加载
    闭包
    Swift 类的构造函数
  • 原文地址:https://www.cnblogs.com/gudanaimei/p/14381993.html
Copyright © 2020-2023  润新知