I am running docker containers on windows local PC.
and set port forwarding on my local router to enable external entering.
/etc/nginx/conf.d/default.conf
is below.
I tried allow xxx.xxx.xxx.xxx; and deny all;. But not worked
Now I am using if statements to allow specific IPs. But not work too.
I want to allow IPs to enter to specific url path.
How to fix it?
upstream django_server {
server host.docker.internal:8888;
}
server {
listen 8080;
listen [::]:8080;
server_name 127.0.0.1;
location / {
set $allow false;
if ($http_x_forwarded_for ~ "172.18.0.1?$") {
set $allow true;
}
if ($http_x_forwarded_for ~ "127.0.0.1?$") {
set $allow true;
}
if ($http_x_forwarded_for ~ "127.0.0.1?$") {
set $allow true;
}
if ($allow = false) {
return 403;
}
proxy_pass http://django_server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}