title: Nginx request parameters still sent to proxy_pass - how to remove them?
body: <p>I have this nginx conf in my server - </p>
  
  <pre><code>server {
    listen *:80;
    server_name kibana_proxy;
  
    location = /auth {
        internal;
        set $query '';
        if ($request_uri ~* "[^\?]+\?(.*)$") {
           set $query $1;
        }
        # add_header X-debug-message "Parameters being passed $is_args$args" always;
        proxy_pass http://127.0.0.1:8080/login/internal?$query;
    }
  
    location / {
        proxy_pass http://127.0.0.1:5601/;
        proxy_http_version 1.1;
        auth_request /auth;
    }
  
    error_page 404 /404.html;
        location = /40x.html {
    }
  
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root /usr/share/nginx/html;
    }
  }
  </code></pre>
  
  <p>So, after /auth has responded with http status 200, the request parameters are appended to the proxy_pass, which results in a http status 400 error and I can't see the protected webapp (Kibana in this case).</p>
  
  <p>I have tried using <code>proxy_set_header X-Original-URI $request_uri;</code> and appending /auth url with <code>$is_args$args</code> under /auth location, but the request parameters aren't passed to the /auth API, that's why this regex matching and creating a query string ($query).</p>
  
  <p>How do I make sure that the proxy_pass (kibana) url doesn't have any request params?</p>