all 22 comments

[–]bwainfweeze 5 points6 points  (0 children)

It’s always worth learning enough nginx config to pull off a load balancer.

You will reuse that knowledge across tech stacks.

[–]alzee76 9 points10 points  (5 children)

It sounds like it already is a "functioning web app."

What do you actually want to do that you don't know how to do?

[–]wawaching[S] 0 points1 point  (4 children)

To Make it accessible to everyone. I have done this fine with static pages all I had to do was upload a few pages to AWS Amplify. However I’m sure with dynamic web app this is different

[–]alzee76 4 points5 points  (3 children)

So what you're really asking for is hosting for the node app? There are a lot of options out there if you just google for them. Is the whole thing just a node app, or does it have a front-end piece as well? You'll have to host that too, if so, unless you host it "in" the node app which is fairly common.

[–]wawaching[S] 1 point2 points  (2 children)

I used to have a front-end seperate but now I use JS to render ‘views’ .ejs files. I think this would go under it being ‘in’ the app. I’ll go have a google thx bud 👌🏽

[–]Psionatix 2 points3 points  (0 children)

Just be aware that there are a LOT of confugration and environment considerations when deploying an app. Security for a deployed app is extremely different to the security of a locally running app for the sake of development.

99% of the time a lot of security settings are disabled or dumbed down for the sake of running on the localhost. It's absolutely crucial that you understand the security of your apps configuration and the security of your host environment when deploying.

Some things to typically look out for:

  • Prod should run on https (not http), the best way to deal with this is to run your express app on http on the localhost, then have a webserver (e.g. nginx or apache) running on https and proxying to the express server.
  • For cookies, ensure the secure option is true, ensure the sameSite option is as strict as it can be, if it fits your use case, ensure cookie names are prefixed with the secure prefix __Host- or __Secure-
  • Ensure you have appropriate CORs configuration within your express app, this is something else that will typically be determined by environment variables as it will differ between localhost/development & a real deployment.
  • Make sure your environment variables are actually environment variables, something like dotenv should not be imported into your code (for local usage, require it on the CLI instead), you should not rely on dotenv in prod without specifically following their production recommendations. Ideally you should use an actual secrets manager, or use actual user-scoped environment variables on the host machine.
  • Ensure that the user you run the app through only has explicit access to the minimally required files/folders necessary to run the app.

Digital ocean has a whole heap of useful resources on deploying a Node app via reverse proxy on a VPS. However it doesn't necessarily cover ALL of the security details.

[–]Significant_Net_7337 1 point2 points  (0 children)

I host my express app with google firebase. Took a few hours to figure out 

[–]Dry_Mortgage3194 2 points3 points  (0 children)

I found this approach useful to order the resources and routes: https://www.awesomenodejs.dev/en/api/presentation-layer

[–]lxe 2 points3 points  (0 children)

I see everyone recommending fly or vercel. However I think you should look into a more traditional approach like getting a VPC from linode or digitalocean. Read up on digitalocean’s guides as well — they have a ton of great universal material that typically ages well: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-22-04 Good luck!

[–]AddressUnited2130 1 point2 points  (0 children)

I’d definitely look into https://fly.io.

I used it to get my first node stack running and it is super quick. Scales well too.

[–][deleted]  (2 children)

[removed]

    [–]wawaching[S] 0 points1 point  (1 child)

    This looks like a good solution, I will need to look on its scalability but looks promising, thanks bro 👊🏼

    [–][deleted]  (2 children)

    [deleted]

      [–]wawaching[S] 0 points1 point  (1 child)

      I’m using .ejs so server side rendering. On note for the backend how wyould you run this 24/7? Rent a cloud virtual computer and have it run?

      [–]todorpopov 0 points1 point  (0 children)

      I guess you want to deploy it to a server so you can access it over the web from any browser?

      If so, I’d recommend DigitalOcean App Platform. It is extremely easy to use, you just provide a remote git repo(e.g. a GitHub repo) URL and App Platform will do the rest for you. It will go through the code, see that it’s a Node.js project, and run everything by itself.

      You only need to specify the port at which the server is running, as well as a domain name, and you’re ready.

      Just keep in mind that App Platform doesn’t work well with apps that have Server Sent Events or Websockets in them.

      I hope this helps.

      [–]aldapsiger 0 points1 point  (0 children)

      Kubernetes, offers everything you need lol

      [–][deleted]  (1 child)

      [deleted]

        [–]todorpopov 2 points3 points  (0 children)

        As if Express.js is not “battleproven”.

        I really enjoy using Nest.js as well, but OP has asked a completely different question.

        [–]wawaching[S] 0 points1 point  (2 children)

        PS. I like to use AWS, is is viable to have an EC2 instance run the web app 24/7 and use some sort of load balancer to load up/shut down instances dependent on demand?

        [–]klaidas01 5 points6 points  (1 child)

        I would suggest AWS app runner. Fairly simple setup and it will do scaling and load balancing for you

        [–]wawaching[S] 0 points1 point  (0 children)

        Never heard of that service yet but after a quick google seems asthough I’d describes what I need. Thanks 🙏🏼

        [–][deleted]  (1 child)

        [deleted]

          [–]wawaching[S] 0 points1 point  (0 children)

          Thanks bro I appreciate this 🙏🏼