Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is there a way to proxy pass based on query parameters? I need to proxy pass root url request to server A. But, if root url has certain query parameters i need to proxy pass to server B. How can i achieve this? Below is my current configuration:

    location / {
        proxy_pass  http://xxxxxx;
        proxy_redirect     off;
        proxy_set_header   Host             $host:$server_port;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        client_max_body_size 10m;
share|improve this question

1 Answer 1

up vote 1 down vote accepted

You could use if statements and intermediate variables, since proxy_pass itself cannot be inside of an if statement.

location / {
    set $pp_d;
    if ($arg_tld = com) {
        set $pp_d;
    proxy_pass http://$pp_d;
    proxy_redirect off;
share|improve this answer

Your Answer


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.