Я пытаюсь настроить Basic-Auth с белым списком IP-адресов в док-контейнере nginx. Но похоже, что nginx не обрабатывает удаленный IP-адрес нормально, из-за "proxy_set_header X-Real-IP $remote_addr;"
Каков наилучший способ добиться этого?
Я уже пытался установить:
proxy_set_header REMOTE_ADDR $remote_addr;
и:
set_real_ip_from xxx.xxx.xxx.xx;
real_ip_recursive on;
upstream django {
server django:8000 fail_timeout=0;
}
server {
listen 80 default_server;
#server_name localhost;
location ^~ /media {
alias /usr/share/nginx/html;
autoindex on;
}
location / {
try_files $uri @django_proxy;
satisfy any;
allow 212.xxx.xxx.26;
allow 212.xxx.xxx.239;
allow 192.168.99.30;
deny all;
auth_basic "authentication required";
auth_basic_user_file /srv/.htpasswd;
}
location @django_proxy {
fastcgi_read_timeout 300;
proxy_read_timeout 300;
set_real_ip_from 212.xxx.xxx.26;
real_ip_recursive on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_pass http://django;
proxy_set_header REMOTE_ADDR $remote_addr;
}
}
фактический результат состоит в том, что он всегда показывает Basic Auth
ожидаемый результат будет таким, что в офисе нет Basic Auth