Folder Structure for Nodejs Multi Subdomain

So, I am building a website using NodeJS where I will use Nginx as a reverse proxy for my application / applications. I will use jade and exchange some layouts between the subdomain and the display of certain content according to the subdomain. I am trying to figure out from many studies the best way to structure an application. Best way to run each subdomain in a separate application on the same server? Or can I bundle them as one application? Please share your ideas and suggestions so that I can make a decision and start my coding :)

+5
source share
2 answers

A major issue when using the same domain in multiple applications is cookie security. If the applications are independent, you might want to make sure that a vulnerability in one application does not necessarily affect your other applications.

Otherwise, with nginx, there really are no restrictions on your installation, however you decided to go. You can use nginx to easily combine or disconnect multiple domains and / or ports / servers into any setting you want.

If you decide to go with multiple domains or multiple paths in the same domain, you will have more to do with what applications you have in mind and how to logically separate them from each other. Using the rewrite directive, even if you make the wrong choice first, if you have the desire, you can always fix it later (keeping all existing links flawlessly), largely without any bad effect.

+4
source

I run several web applications (completely separated in different folders and working on different ports) on a server with nxinx as a proxy for different subdomains. However, if you want to make more subdomains for one application, the best way would be to structure it by URL.

For example, you have mysite.com/books , but you want books.mysite.com to books.mysite.com to the books.mysite.com domain. You do proxies in nginx configurations to redirect traffic from mysite.com/books to books.mysite.com .

+2
source

Source: https://habr.com/ru/post/1261781/


All Articles