0

I have the following conf. I am trying to set a cookie with a value which I extracted in the rewrite rule. But the value of the cookie being always set to null. Is it a problem with the regex or I am trying to do something wrong here. I am completely new to apache httpd.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)uname=(.*)
RewriteRule ^/(.*)&uname=(.*)$ /$1 [env=GRAFANA_UNAME:%2,L,PT]

RewriteCond %{HTTP_COOKIE} uname=(.*)
RewriteRule ^(.*)$ "-" [env=GRAFANA_UNAME:%1,L,PT]

RequestHeader set X-WEBAUTH-USER %{GRAFANA_UNAME}e

RequestHeader unset Authorization

ProxyRequests Off
ProxyPass "/" http://localhost:3000/
ProxyPassReverse "/" http://localhost:3000/

Header always set Set-Cookie "uname=%{GRAFANA_UNAME}e;path=/;HttpOnly"

When I do uname=%{GRAFANA_UNAME}e the cookie value is being set to null always. How do I get the value of uname in the response header.

Niranjan
  • 517
  • 2
  • 4
  • 21

1 Answers1

0

Your rules imply these directives are not in htaccess, but my assumption is that an internal redirect happens nonetheless before your request is really processed.

Try accessing REDIRECT_GRAFANA_UNAME. That prefix is added each time an internal redirect occurs to differentiate between the environment of the current and previous request.

covener
  • 17,402
  • 2
  • 31
  • 45