Back
Question
Is something like Nginx / Reverse Proxy worth it in Node?
Currently using Heroku and serving the files like so:
app.use(express.static(path.join(__dirname, "public")));
I've looked into reverse proxy servers before but always found it complicated. . But from what I've read it would help out a lot. Maybe its time to make the leap.
How simple is Nginx set up? Can anyone point me in the right direction/ tutorials / videos cause it looks tricky. Obviously I need to link the domain name also. Thanks :)
app.use(express.static(path.join(__dirname, "public")));
I've looked into reverse proxy servers before but always found it complicated. . But from what I've read it would help out a lot. Maybe its time to make the leap.
How simple is Nginx set up? Can anyone point me in the right direction/ tutorials / videos cause it looks tricky. Obviously I need to link the domain name also. Thanks :)
👋 Join WIP to participate
Apparently if I'm using Heroku a reverse proxy may not be necessary. IF this is true then the question becomes should I be serving my static files locally or using some sort of CDN.
And if I'm using a CDN how does that exactly work?
Hey man, let me share one cool trick with you! :) There is no need to move assets to the CDN provider manually. You can do the following. Firstly, deploy everything to heroku and make sure that assets are available. Then you need to get an AWS account and use cloudfront. Cloudfront allows to set up a CDN proxy. You just provide it with a link to your asset path on your website. Then you create a CDN distribution and use it in your html. In order to see local images during development you can set up a switch to local path based on the current environment. The link would switch to localhost locally and to CDN distribution in production.
hey max, this sounds cool. thanks so much. got a few questions though:
a) so if my bundle.js is found here: hd001.herokuapp.com/dist/bund…
would my asset path be hd001.herokuapp.com/dist/ ?
but then i have some images uploaded by users here:
hd001.herokuapp.com/uploads/0… ?
So cant really work out my asset path
serving assets out of this public directory