Deploy multiple site in my own server

Is there any way to deploy multiple sites to my own server with forever/pm2 and nginx? How can I call (serve) both sites?

Ex:
$ node app.js --port 3001 // to es version
$ node app.js --port 3000 // to pt version

Regards

Hi @christian.nascimento,

You don’t need to start node twice if you don’t want to. You can use multiple sites in a single installation.

For example, if your Spanish site always starts with my-site.com/es/, you could do:

// frontity.settings.js
export default [
  {
    name: "spanish",
    match: "http:\\/\\/localhost:3000\\/es\\/?" // Regexp to match /es/,
    state: { ... },
    packages: [ ... ]
  },
  {
    name: "portuguese",
    state: { ... },
    packages: [ ... ]
  }
];

Then, run npx frontity build to generate the files in production mode and add the command npx frontity serve (or npm run serve) to forever/pm2.

Depending on your Nginx configuration, you may have to set the match to localhost or to my-site.com. Or you can accept any domain with a Regexp like this one:

match: "https?:\\/\\/([^\\/]+)\\/es(\\/|$)"

This is what the Regexp means:

  • http: starts with http.
  • ?s: then it can have a s or not (for http and https).
  • \\/\\/: then it has //. We need to escaped twice the / with \\.
  • ([^\\/]+): then it has any number of characters until it finds a /. With this, we match the whole domain, including the port.
  • \\/es: then it has /es. This is what actually we want to check.
  • (\\/|$): finally, it has either a / or the string ends here ($). With that we ensure we don’t match things like /estimate that starts with /es but shouldn’t belong to the Spanish site.

Regexp tests here: https://regex101.com/r/ECeZ4m/2

Oh, and if you don’t specify a match (like here for your Porteguese site) Frontity will use it as default.

If you have any problem with this approach let us know :slight_smile:

Thanks very much @luisherranz

Yout solution worked like a charm here :smiley:

I’m getting some troubles with memory allocation when updating a page.

Ex: When I’m typing a code like const s === “Some String”; and I fix it for const s = “Some String”

I’m getting the following error: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Is there any issue about it?

Regards

I’m glad it worked :slight_smile:

Is this your problem?

I think no… :thinking:

I just update the packages and the problem was solved. Thanks very much. :wink:

1 Like

Ok. If it appears again please let us know :slight_smile: