Mahesh H Viraktamath
Mahesh H Viraktamath

Reputation: 884

Nginx request parameters still sent to proxy_pass - how to remove them?

I have this nginx conf in my server -

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

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).

I have tried using proxy_set_header X-Original-URI $request_uri; and appending /auth url with $is_args$args 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).

How do I make sure that the proxy_pass (kibana) url doesn't have any request params?

Upvotes: 0

Views: 1963

Answers (0)

Related Questions