I have an AWS ALB and it is attached to multiple domain names. The ALB forwards the traffic to a EC2 machine with NGINX, here NGINX also has multiple domains associated with it.
I want to allow access to one of my domains from specific IP’s only. And all other domains should be accessible from 0.0.0.0/0.
Can this be done by modifying the configuration file for that domain only rather than modifying nginx.conf(such that the setting will be applicable to one domain alone)
P.S. The restrictions should be applicable only for a single domain.
Below mentioned lines in the configuration worked for me
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
real_ip_header X-Forwarded-For;
set_real_ip_from 10.0.0.0/16;
allow XX.XX.XX.XX/32;
allow XX.XX.XX.XX/32;
allow XX.XX.XX.XX/32;
allow 10.0.0.0/16;
deny all;
Here 10.0.0.0/16; is the IP CIDR of the VPC which allows access from the ALB.