Have you managed to make your node nginx proxy setup on Heroku work?
I have used a Node.js + NGINX setup on heroku for many projects.This way, you can have nginx handle serving static files, caching, proxying to other servers, and proxying to several node processes.
Use the multi-buildpack buildpack (https://github.com/ddollar/heroku-buildpack-multi).
It allows you to specify a .buildpacks file which refers to several buildpacks.In my .buildpacks file, I use the default Heroku Node buildpack, and a fork of an nginx buildpack that I rebuilt to include SSL support.
https://github.com/theoephraim/nginx-buildpack.githttps://github.com/heroku/heroku-buildpack-nodejs.git
The nginx buildpack uses a nginx.conf.erb file that can reference ENV vars. You must tell it to listen on the port specified by heroku in the environment variable called "PORT"
listen <%= ENV["PORT"] %>;
Then you have your node server start up on whatever port you choose, say 5001, and in your nginx config, you can set up a proxy pass to your node app:
location / { proxy_pass http://127.0.0.1:5001;}
Note - your procfile needs to use a special start-nginx command (part of the nginx buildpack) that then calls whatever else you pass it. In my case I use forever to run my node app:
web: bin/start-nginx ./node_modules/.bin/forever app.js
And within your main node file, you must create a file when it has started up successfully to signal to the nginx buildpack that it should begin listening
fs.openSync('/tmp/app-initialized', 'w');
There is a full explanation of how to use the nginx buildpack in the readme @ https://github.com/theoephraim/nginx-buildpack
On Heroku, this setup is used in production by me successfully once the buildpack is installed:
upstream node_entry { server unix:/tmp/nginx.socket fail_timeout=0;}server { listen <%= ENV['PORT'] %>; server_name localhost; keepalive_timeout 5; location / { [other settings…] proxy_pass http://node_entry; }}
Then, in your app.js file you can connect with:
Server.listen(‘/tmp/nginx.socket’);