Welcome! Log In Create A New Profile

Advanced

How to return a cookie to a client when auth_request is used?

January 15, 2015 03:11AM
Hi,

Question 1:

I would like to have an FastCGI authentication app assign a cookie to a client, and the Fast Auth app is called using auth_request. The steps are as follows:

1. Client sends a request
2. NGINX auth_request forwards the request to a FastCGI app to authenticate.
3. The authentication FastCGI app creates a cookie, using "Set-Cookie: name=value". I would like this value to be returned to the client.
4. Assuming the authentication was successful, NGINX then forwards the request to an upstream FastCGI app which sends a response to the client. The HTTP header should contain Set-Cookie: name=value

How do I get NGINX to include the cookie in the header that gets forwarded to the upstream module so the final response to the client contains the cookie? I tried using auth_request_set but got

location / {

auth_request /auth;
include fastcgi_params;
fastcgi_param HTTP_COOKIE $http_cookie;
#auth_request_set $http_cookie "test"; <======= I tried this just to see how auth_request_set works. NGINX j

fastcgi_pass 127.0.0.1:9000;
}

# new fastcgi to set the cookie
location /auth {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9010;
}

Question 2. I also tried
auth_request_set $http_cookie "test";
to see how auth_request_set works. NGINX gave me this error at start time

nginx: [emerg] the duplicate "http_cookie" variable in /usr/local/nginx-1.7.9/conf/nginxWat.conf:25

Why did get such error?

Question 3. Can someone give me a pointer to a list of NGINX FastCGI supported env variables such as $http_cookie / HTTP_COOKIE?

Thank you!
Subject Author Posted

How to return a cookie to a client when auth_request is used?

nginxuser100 January 15, 2015 03:11AM

Re: How to return a cookie to a client when auth_request is used?

Maxim Dounin January 15, 2015 08:18AM

Re: How to return a cookie to a client when auth_request is used?

nginxuser100 January 18, 2015 08:50PM

Re: How to return a cookie to a client when auth_request is used?

nginxuser100 January 21, 2015 02:47PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 228
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready