Skip to content

Commit

Permalink
Fix issue #118
Browse files Browse the repository at this point in the history
  • Loading branch information
joglomedia committed Dec 6, 2021
1 parent 889d152 commit 7c3fb8f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ http {
# SSL map.
include /etc/nginx/fastcgi_https_map;

# Let NGINX get the real client IP for its access logs. You can move this to server{} block.
# Let NGiNX get the real client IP for its access logs. You can move this to server{} block.
# Uncomment if you're using frontend http accelerator or loadbalancer such as haproxy/varnish.
#include /etc/nginx/http_proxy_ips;

Expand Down
44 changes: 29 additions & 15 deletions etc/nginx/vhost/site_wordpress-bwps.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
## WP + BWPS plugin rewrite rules.
# Designed to be included in any server {} block.

# Include Wordpress single-site configuration.
include /etc/nginx/vhost/site_wordpress.conf;

# BEGIN Better WP Security

# COMMENTED as restrictions already handled by default LEMPer configuration.
Expand Down Expand Up @@ -58,19 +52,39 @@ if ($http_cookie !~* "wordpress_logged_in_" ) {
if ($args !~ "^loggedout=true") { set $susquery 3$susquery; }
if ($susquery = 4321) { return 403; }

rewrite ^/login/?$ /wp-login.php?np5eou1moyhmux2kmzyps redirect;
#rewrite ^/login/?$ /wp-login.php?np5eou1moyhmux2kmzyps redirect;
location ~ ^/login/?$ {
return 302 /wp-login.php?np5eou1moyhmux2kmzyps;
}

if ($rule_2 = 1) { rewrite ^/dashboard/?$ /wp-login.php?np5eou1moyhmux2kmzyps&redirect_to=/wp-admin/ redirect; }
if ($rule_2 = 0) { rewrite ^/dashboard/?$ /wp-admin/?np5eou1moyhmux2kmzyps redirect; }
#if ($rule_2 = 1) { rewrite ^/dashboard/?$ /wp-login.php?np5eou1moyhmux2kmzyps&redirect_to=/wp-admin/ redirect; }
#if ($rule_2 = 0) { rewrite ^/dashboard/?$ /wp-admin/?np5eou1moyhmux2kmzyps redirect; }
location ~ ^/dashboard/?$ {
if ($rule_2 = 1) { return 302 /wp-login.php?np5eou1moyhmux2kmzyps&redirect_to=/wp-admin/; }
if ($rule_2 = 0) { return 302 /wp-admin/?np5eou1moyhmux2kmzyps; }
}

rewrite ^/register/?$ /wp-login.php?np5eou1moyhmux2kmzyps&action=register redirect;
#rewrite ^/register/?$ /wp-login.php?np5eou1moyhmux2kmzyps&action=register redirect;
location ~ ^/register/?$ {
return 302 /wp-login.php?np5eou1moyhmux2kmzyps&action=register;
}

if ($uri !~ "^(.*)admin-ajax.php") { set $rule_3 2$rule_3; }
if ($http_referer !~* wp-admin ) { set $rule_3 3$rule_3; }
if ($http_referer !~* wp-login.php ) { set $rule_3 4$rule_3; }
if ($http_referer !~* login ) { set $rule_3 5$rule_3; }
if ($http_referer !~* dashboard ) { set $rule_3 6$rule_3; }
if ($http_referer !~* register ) { set $rule_3 7$rule_3; }

#if ($http_referer !~* wp-admin ) { set $rule_3 3$rule_3; }
#if ($http_referer !~* wp-login.php ) { set $rule_3 4$rule_3; }
#if ($http_referer !~* login ) { set $rule_3 5$rule_3; }
#if ($http_referer !~* dashboard ) { set $rule_3 6$rule_3; }
#if ($http_referer !~* register ) { set $rule_3 7$rule_3; }
map $http_referer $rule_3 {
default $rule_3;
!~*/wp-admin/ 3$rule_3;
!~*/wp-login.php 4$rule_3;
!~*/login 5$rule_3;
!~*/dashboard 6$rule_3;
!~*/register 7$rule_3;
}

if ($args !~ "^action=logout") { set $rule_3 8$rule_3; }
if ($args !~ "^np5eou1moyhmux2kmzyps") { set $rule_3 9$rule_3; }
if ($args !~ "^action=rp") { set $rule_3 0$rule_3; }
Expand Down
6 changes: 3 additions & 3 deletions etc/nginx/vhost/site_wordpress-ms.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ include /etc/nginx/vhost/site_wordpress.conf;

# Directive to avoid php readfile() for WordPress Multisite.
# The $root_path variable must be predefined in your vhost config file, use 'set' inside server{} block or 'map' before server{} block.
location ^~ /blogs.dir {
location ^~ /blogs.dir/ {
internal;
alias $root_path/wp-content/blogs.dir;
alias $root_path/wp-content/blogs.dir/;
access_log off;
log_not_found off;
expires max;
Expand All @@ -24,7 +24,7 @@ location ~ ^/[_0-9a-zA-Z-]+/files/(.*)$ {

# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}

0 comments on commit 7c3fb8f

Please sign in to comment.