Created
November 22, 2024 09:09
-
-
Save romandobra/79c7bfd99590395db1a5a1d4f070a66d to your computer and use it in GitHub Desktop.
nginx_cookie_auth.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location / { | |
if (!-f /var/www/auth_cookies/$cookie_AUTH_COOKIE) { | |
add_header Content-Type text/html; | |
return 200 '<form><input name="auth_cookie"><button type="submit">AUTH</button></form><script> | |
const f=new Proxy(new URLSearchParams(window.location.search),{get:(searchParams,prop)=>searchParams.get(prop),}); | |
if (!f.auth_cookie == ""){document.cookie="AUTH_COOKIE="+f.auth_cookie+"; Expires=Thu, 01 Jan 2070 00:00:01 GMT"; | |
window.location.replace("$scheme://$server_name/")}; | |
</script>'; | |
} | |
try_files $uri $uri/ =404; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment