<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi Francis</div><div>   I tried to set cookies like this</div><div><br></div><div><div><div>server {</div><div>  listen 80;</div><div>  server_name datanode02.bddev.test.net;</div><div>  error_log  /var/log/nginx/error_for_bigdata.log  info;</div><div>  access_log  /var/log/nginx/http_access_for_bigdata.log  main;</div><div><span style="color: rgb(255, 0, 0);">  ##here to check whether logged_in cookie was set</span></div><div><span style="color: rgb(255, 0, 0);">  if ($cookie_logged_in != "1") {</span><br></div><div>       auth_ldap "Restricted Space";</div><div>       auth_ldap_servers bigdataldap;</div><div><span style="color: rgb(255, 0, 0);"> }</span><br></div><div><br></div><div>  location / {</div><div>           proxy_pass http://dev-datanode02:8042/;</div><div>           more_clear_headers "X-Frame-options";</div><div>           <span style="color: rgb(255, 0, 0);">add_header Set-Cookie "logged_in=1;Domain=.bddev.test.net;Path=/;Max-Age=315360000";</span><br></div><div>  }</div><div>}</div><div>server {</div><div>  listen 80;</div><div>  server_name datanode03.bddev.test.net;</div><div>  error_log  /var/log/nginx/error_for_bigdata.log  info;</div><div>  access_log  /var/log/nginx/http_access_for_bigdata.log  main;</div><div><span style="color: rgb(255, 0, 0);">  ##here to check whether logged_in cookie was set<br></span></div><div><span style="color: rgb(255, 0, 0);">  if ($cookie_logged_in != "1") {</span><br></div><div>       auth_ldap "Restricted Space";</div><div>       auth_ldap_servers bigdataldap;</div><div><span style="color: rgb(255, 0, 0);">  }</span><br></div><div>  location / {</div><div>           proxy_pass http://dev-datanode03:8042/;</div><div>           more_clear_headers "X-Frame-options";</div><div>           <span style="color: rgb(255, 0, 0);">add_header Set-Cookie "logged_in=1;Domain=.bddev.test.net;Path=/;Max-Age=315360000";</span></div>  }</div>}</div>but nginx failed to start,<br><img src="http://mail.126.com/js6/s?func=mbox:getMessageData&sid=*&mid=41:1tbiKQyCSFpD771noQAAsi&part=3" style="width: 1196px; height: 269px;" data-image="1"><div>seem it is not possible to set <br></div><div>   auth_ldap "Restricted Space";<br>   auth_ldap_servers bigdataldap;</div><div>in  "if" block like this,</div><div>do you know how to skip the auth_ldap_servers setting when logged_in cookie is set?</div><div>Thanks<br></div><br><br><br><br><div style="position:relative;zoom:1"></div><div id="divNeteaseMailCard"></div><br><pre><br>At 2019-03-22 16:03:23, "Francis Daly" <francis@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@daoine.org
>_______________________________________________
>nginx mailing list
>nginx@nginx.org
>http://mailman.nginx.org/mailman/listinfo/nginx
</pre></div><br><br><span title="neteasefooter"><p> </p></span></div><br><br><span title="neteasefooter"><p> </p></span>