Skip to content

Instantly share code, notes, and snippets.

@badpenguin
Created July 7, 2018 18:59
Show Gist options
  • Save badpenguin/e1993eda055aa0f8d2f25bd699689328 to your computer and use it in GitHub Desktop.
Save badpenguin/e1993eda055aa0f8d2f25bd699689328 to your computer and use it in GitHub Desktop.
Allow access to Wordpress only if user has passed thru another page first and gathered a special cookie
set $cicciopasticcio 0;
if ($request_uri ~* "/wp-admin|/wp-login.php") {
set $cicciopasticcio 1;
}
if ($request_uri ~* "/wp-admin/admin-ajax.php") {
set $cicciopasticcio 0;
}
if ($cookie_cicciopasticcio != "nginx") {
set $cicciopasticcio "${cicciopasticcio}1";
}
if ($cicciopasticcio = 11) {
return 404;
}
location = /cicciopasticcio.php {
add_header X-Debug "cicciopasticcio" always;
set $cache_skip 1;
set $cache_uri '';
add_header Set-Cookie "cicciopasticcio=nginx;path=/;max-age=3153600000";
return 302 /wp-login.php;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment