我在/ wp目录下有一个wordpress网站,用nginx web服务器。我想限制/ wp / wp-admin文件到我的私有IP地址,并向无通气的客户端返回一个错误。 问题是wp-admin文件夹可以很容易地被限制,但文件仍然可以访问!
server { root /usr/share/nginx/html; index index.html index.htm index.php; listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location /main { index index.php; try_files $uri $uri/ /wp/index.php?q=$uri; } error_page 500 502 503 504 404 403 400 /error.html; location = /error.html { root /usr/share/nginx/html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
要做到这一点的方法是在您的configuration文件中的location节,如:
location /wp/wp-admin/ { allow 192.168.1.0/24; deny all; }
你的问题听起来好像你已经尝试过,但没有成功? 你能发布你的确切configuration这个目录?