• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Question Blocking access to wp-admin with nginx directive

Rooked

New Pleskian
Server operating system version
CentOS Linux 8.5.2111
Plesk version and microupdate number
Version 18.0.41 Update #1
Hello! I'd like to block access to /wp-admin and /wp-login on my Wordpress website for everybody except a specific IP-address. My site doesn't have proxy mode turned on but when I add the below nginx directive to my settings I can still get to /wp-admin:

Code:
location ~ /(wp-login|wp-admin/) {
    allow 1.2.3.4;
    deny all;
}

I've been Googling and trying different snippets, like
Code:
location ~ ^/(wp-admin|wp-login\.php) {
but none seem to work. Can I not add it directly in plesk, do I need to edit the config file directly on the server? Or is it something else I'm doing wrong?

My entire Additional nginx directives, in case it's relevant:

Code:
proxy_connect_timeout       600;
proxy_send_timeout          600;
send_timeout                600;
fastcgi_read_timeout        300;

fastcgi_buffers 128 4096k;
fastcgi_buffer_size 4096k;

location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}

location ~ /(wp-login|wp-admin/) {
    allow 1.2.3.4;
    deny all;
}

location ~* \.(?:css|js|jpg|jpeg|png|gif|ico|ttf|woff|woff2|svg|otf|eot)$ {
    expires 30d;
    access_log off;
    log_not_found off;
    add_header Pragma public;
    add_header Cache-Control "public";
    try_files $uri @fallback;
}

# Source: https://www.websavers.org/how-to-speed-up-wordpress/
rewrite !\.(js|ico|gif|jpg|png|css|pdf|mov|mp3|eot|svg|ttf|woff|woff2|otf|txt|swf)$ /index.php break;
rewrite /wp-admin/$ /wp-admin/index.php break;

if (!-e $request_filename){
    rewrite ^(.*)$ /index.php break;
}
 
Back
Top