Ah I faced this issue today and was able to solve it from multiple places; For anyone facing similar issue i thought ill try to help you out
the 403 error occurs because most probably your server is not listening to the request directly from the client, ie either a loadbalancer or proxy gives the request to nginx.
to solve this use
set_real_ip_from 34.117.182.58/0;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
under http block (note http not server) ie
http {
set_real_ip_from 34.117.182.58/0; \n
real_ip_header X-Forwarded-For;
real_ip_recursive on;
}
this should solve the 403 error but most likely you will recieve 404 error this is due to how nginx works to solve this add proxy_pass http://backend_server; to the location
eg:
location /admin {
allow 1.2.3.4;
deny all;
proxy_pass http://backend_server;
}
This should solve your issue :) Hope I could be of help