nginx servers share session or cookies
David Ni
zn1314 at 126.com
Mon Mar 25 08:11:50 UTC 2019
Hi Francis
I tried to set cookies like this
server {
listen 80;
server_name datanode02.bddev.test.net;
error_log /var/log/nginx/error_for_bigdata.log info;
access_log /var/log/nginx/http_access_for_bigdata.log main;
##here to check whether logged_in cookie was set
if ($cookie_logged_in != "1") {
auth_ldap "Restricted Space";
auth_ldap_servers bigdataldap;
}
location / {
proxy_pass http://dev-datanode02:8042/;
more_clear_headers "X-Frame-options";
add_header Set-Cookie "logged_in=1;Domain=.bddev.test.net;Path=/;Max-Age=315360000";
}
}
server {
listen 80;
server_name datanode03.bddev.test.net;
error_log /var/log/nginx/error_for_bigdata.log info;
access_log /var/log/nginx/http_access_for_bigdata.log main;
##here to check whether logged_in cookie was set
if ($cookie_logged_in != "1") {
auth_ldap "Restricted Space";
auth_ldap_servers bigdataldap;
}
location / {
proxy_pass http://dev-datanode03:8042/;
more_clear_headers "X-Frame-options";
add_header Set-Cookie "logged_in=1;Domain=.bddev.test.net;Path=/;Max-Age=315360000";
}
}
but nginx failed to start,
seem it is not possible to set
auth_ldap "Restricted Space";
auth_ldap_servers bigdataldap;
in "if" block like this,
do you know how to skip the auth_ldap_servers setting when logged_in cookie is set?
Thanks
At 2019-03-22 16:03:23, "Francis Daly" <francis at daoine.org> wrote:
>On Fri, Mar 22, 2019 at 02:47:36PM +0800, David Ni wrote:
>
>Hi there,
>
>> Who can help with this?Thanks very much.
>
>The question looks very like the one at
>https://forum.nginx.org/read.php?2,282620,282620
>
>I presume that the answer remains the same.
>
>Which is: if "Domain" works for you, add it to the place that creates (or
>causes to be sent to the client) the "Set-Cookie" http response header.
>
> f
>--
>Francis Daly francis at daoine.org
>_______________________________________________
>nginx mailing list
>nginx at nginx.org
>http://mailman.nginx.org/mailman/listinfo/nginx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190325/615a1dcf/attachment.html>
More information about the nginx
mailing list