Nginx URI匹配规则


server {
        listen       80;
        server_name  kevin.com;
        access_log  logs/book_access.log;
        error_log   logs/book_error.log;

        #精确匹配
        #访问事例:http://kevin.com/mr/?name=kevin&age=18&man=1
        #实际获取参数为:{age=18, name=kevin, code=kevin, man=1} 
        location = /mr/ {
            #proxy_set_header Host $host;
            #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://dev1/admin/doc/show.jsp?code=kevin&$args;
        }

        #正则
        #访问事例:http://kevin.com/api/mr/00/kevin.do?name=kebi
        #实际获取参数为:{name=kebi, code=00} 
        location ~ /api/mr/([0-9]+)/kevin.do$ {
            #proxy_set_header Host $host;
            #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://dev1/admin/doc/show.jsp?code=$1&$args;
        }
    }

你可能感兴趣的:(Nginx)