zoukankan      html  css  js  c++  java
  • nginx Location正则表达式

    1. Location正则表达式

    1.1. location的作用

    location指令的作用是根据用户请求的URI来执行不同的应用,也就是根据用户请求的网站URL进行匹配,匹配成功即进行相关的操作。

    1.2. location的语法

    =开头表示精确匹配
    A 中只匹配根目录结尾的请求,后面不能带任何字符串。

    ^~ 开头表示uri以某个常规字符串开头,不是正则匹配

    ~ 开头表示区分大小写的正则匹配;

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

    / 通用匹配, 如果没有其它匹配,任何请求都会匹配到

     

    Location语法可以参考:

    https://www.cnblogs.com/coder-yoyo/p/6346595.html

    1.3. 域名相同,拦截不同的项目名称

     1 server {
     2         listen       80;
     3         server_name  localhost;
     4 
     5     #拦截uri以tomcat_8080开头
     6         location ^~ /tomcat_8080/ {
     7             proxy_pass http://127.0.0.1:8080/;
     8             index  index.html index.htm;
     9         }
    10 
    11     #拦截uri以tomcat_8081开头
    12     location ^~ /tomcat_8081/ {
    13             proxy_pass http://127.0.0.1:8081/;
    14             index  index.html index.htm;
    15         }
    16     }
  • 相关阅读:
    将u8BF7字符串转换为汉字
    ubuntu扩容
    python面试题
    OCR开源项目
    58到家数据库30条军规解读
    dvwa sql盲注教程
    python time模块详解,时间格式转换
    python正则表达式
    tr命令详解
    腐烂
  • 原文地址:https://www.cnblogs.com/itoyr/p/10072357.html
Copyright © 2011-2022 走看看