zoukankan      html  css  js  c++  java
  • [nginx] load balancing & location

    将NGINX配置成7层load balancer,该怎么做?

    参见:

    http://nginx.org/en/docs/http/load_balancing.html

    https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/

    https://www.nginx.com/blog/nginx-load-balance-deployment-models/?_ga=2.46277799.1689967697.1521711772-726225183.1521711772

    其中,分发的一个关键节点是location关键字的值。

    见location命令的描述:http://nginx.org/en/docs/http/ngx_http_core_module.html#location

     摘要:

     1.   描述方式:

      a。 前缀字符串

      b。 正则表达式

        1 大小写敏感

        2  大小写不敏感

     2.  优先匹配顺序。

      a。先检查前缀字符串。

        1. 多个匹配的时候,最长的匹配前缀将被选中并记住。

        2. 当选中的最长前缀由 ”^~“ 进行修饰的时候,将不再检查正则表达式。

      b。 再检查正则表达式。

        1.  按照配置文件中出现的前后顺序逐条检查,遇到第一条匹配时即停止。

        2.  如果没有匹配到正则,之前记录下的最长前缀匹配将被使用。

     3. 正则表达式支持capture

     4. 精准匹配

        使用 “=” 修饰,匹配到之后,匹配将立刻结束。

     5. @符号

        Such a location is not used for a regular request processing, but instead used for request redirection.

     6.

    If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of proxy_pass, fastcgi_pass, uwsgi_pass, 
    scgi_pass, or memcached_pass, then the special processing is performed. In response to a request with URI equal to this string, but without the trailing
    slash, a permanent redirect with the code 301 will be returned to the requested URI with the slash appended. If this is not desired, an exact match of the
    URI and location could be defined like this:

     7. 嵌套的location

      https://serverfault.com/questions/496371/nested-locations-nginx

    读nginx与location相关的代码

  • 相关阅读:
    MySQL实用基本操作
    数组经典例题
    Java基础之流程控制
    Java基础之数组详解
    java基础语法(三大基础)
    golang map转json
    go get 无反应、访问github.com速度慢、没反应问题的解决方案
    微信公众平台,微信网页授权,redirect_uri参数错误,解决方法!
    通过 nginx 访问 golang web
    golang 报错信息及解决方法--采坑之路,学习使我快乐
  • 原文地址:https://www.cnblogs.com/hugetong/p/8625847.html
Copyright © 2011-2022 走看看