Nginx:location正则表达式不起作用



我的正则表达式有问题,不知道它出了什么问题。它返回了一个带有orls/f而不是orls/f?p=4550的URi。当我通过https://secure.toto02.com/orls/myservice/f?p=4550

我的conf文件在下面

 location ~ "^/([a-zA-Z]+)/myservice/(.+)$" {
    error_log  /var/log/nginx/error-server.log notice;
    rewrite_log on;  
    #proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;

    proxy_pass http://192.168.3.45:8080/orls/$2;    
    proxy_redirect http://192.168.3.45:8080/orls/ https://secure.toto02.com/$1/myservice/ ;          
}   

有人能帮忙吗?

捕获位置不会包含查询字符串。您必须通过$is_args$args变量手动包含它,如:

proxy_pass http://192.168.3.45:8080/orls/$2$is_args$args;

相关内容

最新更新