nginx基本身份验证成功后设置cookie和重定向
如何在同一台服务器上的NGINX auth_basic成功后立即设置cookie和重定向 似乎需要某种组合nginx基本身份验证成功后设置cookie和重定向,nginx,Nginx,如何在同一台服务器上的NGINX auth_basic成功后立即设置cookie和重定向 似乎需要某种组合满足,验证基本,或验证请求,但文档仅涵盖将验证外包给某个外部服务器的情况。 提前谢谢。我觉得应该有更好的方法,但是如果您使用内部位置,您可以欺骗尝试使用\u文件 location /cookie-drop { auth_basic "Please authenticate"; auth_basic_user_file /your/htpasswd/file; # Using nu
满足
,验证基本
,或验证请求
,但文档仅涵盖将验证外包给某个外部服务器的情况。
提前谢谢。我觉得应该有更好的方法,但是如果您使用内部位置,您可以欺骗
尝试使用\u文件
location /cookie-drop {
auth_basic "Please authenticate";
auth_basic_user_file /your/htpasswd/file;
# Using null as a hardcoded nonexistent file
try_files null @cookie-drop;
}
location @cookie-drop {
internal;
add_header Set-Cookie "token=foo;Domain=example.com;Path=/";
return 302 https://$host/
}
如果将return 302
放入/cookie drop
位置,它将忽略auth_basic
设置。try\u files
设置是我唯一能找到的重定向到这样一个内部位置的设置。也许有更好的办法