Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure nginx for heroku nodejs web application

How does one configure nginx for a heroku nodejs web application? I would like to configure nginx such that an IP address is limited to N requests for a given time period. Like the classic "You're doing that too much" message as seen on Reddit.

Thanks,

Charles

like image 958
Charles Kenney Avatar asked Aug 19 '17 23:08

Charles Kenney


People also ask

Can I use nginx on Heroku?

Installing Nginx on HerokuYou can run multiple processes and applications in your Dyno by using the Heroku Multi Buildpack in combination with the Heroku Runit Buildpack. This allows you to specify any amount of buildpacks to run on one Dyno.

Can I run NodeJS on Nginx?

For Nginx to route to the Node. js application listening on port 3000, we'll need to first unlink the default configuration of Nginx and then create a new configuration to be used for by our Node. js application. The Nginx configuration is kept in the /etc/nginx/sites-available directory.

Can I host node js on Heroku?

Select NodeJS from the options and click Save changes. Now, go back to the Deploy tab, and click Deploy Branch at the bottom. Heroku will take the code and host it.


1 Answers

Good starting point : heroku/heroku-buildpack-nginx

What you are looking for is rate-limiting with NGINX, read this for a better understanding

and here you have an example gist: NGINX reverse proxy with rate limiting

This is the file of the heroku-nginx-node-example that I think you have to add the limit_req options

If you need more help, show what you have tried so far and I will edit this answer.

like image 143
EMX Avatar answered Oct 05 '22 23:10

EMX