Skip to content

NodeJS Reverse proxy to work on two domains in Ligtsail

0

Hi Everyone,

Have anyone created a lightsail with two fodlers one with Next js and other in Strapi. using PM2 to run with reverse proxy. installed bncert tool.

Any idea how I can achieve these,,

asked 2 years ago238 views

1 Answer
0

Yes, it might be possible to set up a Lightsail instance to host multiple applications (like Next.js and Strapi) using a reverse proxy and PM2. Here's a general approach to achieve this:

- Set up your Lightsail instance with Node.js installed.

- Create static IP addresses for your Lightsail instance to ensure your IP doesn't change when you stop and start the lightsail instance.

- Create two separate folders for your Next.js and Strapi applications. Use PM2 to manage and run both applications. Make sure you configure the two applications to run on different ports.

- Set up a reverse proxy (like Nginx) to route traffic to the correct application based on the domain and port information

- Configure your virtual hosts in the web server to point to the different applications based on the domain name.

- Set up SSL certificates for your domains and applications

- Set up your DNS records to point your domains to the static IP of your Lightsail instance.

Remember to configure your Lightsail firewall to allow traffic on the necessary ports (typically 80 and 443 for HTTP and HTTPS).

For the specific configuration of the reverse proxy, you'll need to set up virtual hosts that listen for requests to each domain and proxy those requests to the appropriate Node.js application (Next.js or Strapi) running on different ports.

Keep in mind that hosting multiple applications on a single Lightsail instance may affect performance, depending on the resources of your chosen instance plan. Monitor your instance's resource usage and consider upgrading if necessary.

Providing some third party discussions on the same below :

https://serverfault.com/questions/1041126/nginx-reverse-proxy-multiple-nodejs-apps-on-same-domain https://stackoverflow.com/questions/64910845/run-multiple-node-js-apps-on-the-same-server https://stackoverflow.com/questions/65205074/lets-encrypt-ssl-for-nodejs-in-lightsail-resource-missing https://world.hey.com/hridel/set-up-an-nginx-virtual-host-as-a-reverse-proxy-2117daab

Sources
Trying to host multiple websites from single Lightsail instance | AWS re:Post
Get started with Node.js on Lightsail - Amazon Lightsail
Create and attach a static IP to your Lightsail instance - Amazon Lightsail

answered 2 years ago

AWS
SUPPORT ENGINEER

revised 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.