简体   繁体   中英

Nginx: location regex not working

i'm getting trouble with my regex don't know what is wrong with it. it's returning a URi with orls/f instead of orls/f?p=4550 . When i pass https://secure.toto02.com/orls/myservice/f?p=4550

my conf file is below

 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/ ;          
}   

Can anyone help?

Capturing the location will not encompass the query string. You have to manually include it via $is_args and $args variables like so:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM