简体   繁体   中英

Nginx + Node.js at Heroku

Do i still to configure nginx if I want to deploy my node.js application on Heroku? or Heroku already handle that part?

If I do need to configure, what are the steps? for those of you who have experienced deploying it on heroku, could you guide me. This will be my first time deploying something for real :)

Thank you

Heroku handles the proxy between your app to port 80 (or SSL port when applicable) for you. But the port for your app is not fixed, it is potentially variable but always available as an Environment Variable PORT .

So in your node.js app, you should listen to process.env.PORT instead of a fixed value. Further, to make the app run both locally and on Heroku environment, you can do process.env.PORT || 3000 process.env.PORT || 3000 assuming 3000 is your choice of the port number for local development purposes.

See https://devcenter.heroku.com/articles/dynos#local-environment-variables for further details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM