zoukankan      html  css  js  c++  java
  • 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一定存在
  • 相关阅读:
    机器学习之路--Python
    机器学习之路--Pandas
    机器学习之路--seaborn
    机器学习之路--Matplotlib
    囫囵吞枣——SVG
    囫囵吞枣——XML
    囫囵吞枣——Jquery 笔记
    囫囵吞枣——JavaScript
    囫囵吞枣——CSS3
    囫囵吞枣——CSS笔记
  • 原文地址:https://www.cnblogs.com/gudanaimei/p/14381993.html
Copyright © 2011-2022 走看看