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

nginxuser100 nginx-forum at
Wed Jan 21 19:47:40 UTC 2015

In case it will help someone else, the problem turned out to be in the
FastCGI auth server's printf, the last "statement" of the HTTP header should
end with \n\n instead of \r\n.

The following was wrong:
printf("Content-type: text/html\n\n"
"Set-Cookie: name=AuthCookie\r\n"
"<html><head><title>FastCGI 9010: Hello!</title></head>\n"

This did the trick:
printf("Content-type: text/html\r\n"
"Set-Cookie: name=AuthCookie\n\n"
"<html><head><title>FastCGI 9010: Hello!</title></head>\n"

Thank you!

Posted at Nginx Forum:,256110,256233#msg-256233

More information about the nginx mailing list