Answer the question
In order to leave comments, you need to log in
NGINX - how to restrict access to content on HTTP_X_REAL_IP?
Good evening.
I have two servers, the first and the second :=)
domain.com is attached to the first server,
on the second server I have domain.com/blog/, that is, when accessing this address, the first server proxies the request to the second server.
Now on the second server I need to set restrictions on the IP address on domain.com/blog/wp-admin/.
The problem is that when proxying to the second server, the real IP address of the visitor is transmitted only via HTTP_X_REAL_IP and my configuration does not work for this reason:
location ~ ^/blog/wp-admin(/?)(.*) {
satisfy any;
allow 10.11.142.234;
allow 10.11.83.210;
allow 10.11.85.50;
allow 10.11.40.2;
allow 10.11.183.98;
auth_basic "Blog";
auth_basic_user_file /etc/nginx/.htpasswd;
deny all;
}
location ~ ^/blog(/?)(.*) {
proxy_set_header Host www.domain.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass https://ip-address:443/blog/$2$is_args$args;
proxy_redirect off;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question