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?

share|improve this question
    
I used escape character `\` in your current regex and I can see it is correctly capturing the groups you want. regex101.com/r/vI6rG3/1. what is the problem ? – apgp88 Apr 7 '15 at 18:13
    
My problem is comming form the second capture it seems to just cature the f and not the f?p=4550.I used what you proposed but it's still not working – skip87 Apr 7 '15 at 18:16
    
Are you sure it's a regex problem? Can't it be that location of nginx does not include query? (I couldn't find out from the docs.) You could try "hard-coding" the second capturing group (something like f\?p=4550) and see what happens... – Attilio Apr 7 '15 at 20:21
    
Try if ($args ~ p=4550) { rewrite ^ http://example.com/ permanent; } – Wiktor Stribiżew Apr 7 '15 at 20:49
up vote 2 down vote accepted

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;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.