How to return a cookie to a client when auth_request is used?
nginxuser100
nginx-forum at nginx.us
Thu Jan 15 08:11:23 UTC 2015
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!
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,256110,256110#msg-256110
More information about the nginx
mailing list