Deny local IP in reverse proxy with NGINX

protoss_666

Cadet
Joined
Jun 8, 2020
Messages
5
Hello everyone,

I have configured a reverse proxy on my FreeNAS with Nginx, my goal is to allow access to my NAS to users of my internal network and deny access to everyone else.


Code:
server {

        listen 443 ssl http2;



        server_name nas.mydomain.tk;

        access_log /var/log/nginx/nas.access.log;

        error_log /var/log/nginx/nas.error.log;



        include snippets/mydomain.tk.cert.conf;

        include snippets/ssl-params.conf;



        location / {

                include snippets/proxy-params.conf;

                include snippets/internal-access-rules.conf;

                proxy_pass http://107.XXX.XXX.XXX/;

        }

}


In proxy-params.conf I have configured:

Code:
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_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;


In internal-access-rules.conf I have:

Code:
allow 192.168.1.0/24;
deny all;



Then I have restarted the Nginx:

Code:
service nginx reload



I have tried to access my domain nas.mydomain.tk from another network but my server is accessible worldwide. I just want it to be accessible through my internal network.
That could be happening?



Alex
 
Top