-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does this nginx has ngx_http_access_module? #27
Comments
allow
and deny
ip rules?
ngx_http_access_module is compiled by default https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#selecting-the-nginx-modules-to-build and since it is not explicitly excluded in scripts/build_nginx it should be included in the buildpack. |
I just ran into this as well. The issue is that nginx is using the Heroku router's IP by default since the router is proxying the request. We need to use the Real IP module (which is included in this buildback) to let nginx know what the actual client IP is. Add it to the server block in the nginx.conf.erb file: server {
listen <%= ENV["PORT"] %>;
server_name _;
keepalive_timeout 5;
# Add the below 2 lines
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;
# ... rest of your config Typically you're supposed to whitelist the addresses of your proxy servers, but in this case, we can't know them because of how Heroku works. Setting I added the
Once you do this, you can use allow/deny like you normally would. |
I am trying to use nginx to whitelist the IPs allowing to access to my heroku app.
by https://serverfault.com/a/844504/506273, for test purpose, I setup the below config for file
config/nginx.conf.erb
It does not work at all(for rejecting access to my heroku app from all ips).
Any suggestion? Is it due to my issue or something else?
BTW,
heroku-buildpack-nginx
seems good. My rails frontend is driven by Nginx, except it cannot whitelist the ips.The text was updated successfully, but these errors were encountered: