nginx proxy - how to allow connection from a specific ip -


i've installed nginx , set forward proxy (see attached nginx.conf) server became overloaded , seems else using it.

is there way limit nginx proxy receive request specific ips?

please explain how should change nginx.conf ip 123.456.123.345

worker_processes  1;  events {     worker_connections  1024; }  http {     include       mime.types;     default_type  application/octet-stream;      sendfile        on;     keepalive_timeout  65;      gzip  on;      server {         listen       8080;          location / {             resolver 8.8.8.8;             proxy_pass http://$http_host$uri$is_args$args;         }          error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   html;         }     } } 

do this:

location / {     allow 123.456.123.345;     deny  all;     resolver 8.8.8.8;     proxy_pass http://$http_host$uri$is_args$args; } 

from docs:

the rules checked in sequence until first match found.

so if ip equals 123.456.123.345, access allowed, otherwise - denied.

if want allow multiple ips, can specify them before deny all;:

allow 123.456.123.345; allow 345.123.456.123; deny  all; 

"location" directive should inside 'server' directive


Comments