Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Run multiple web apps with single nginx server

I have 3 apps written in node js using the express module. Every app supports http and https. I created that for three different ports. I want to run all apps in a single pc with single IP but different domains. I have a linux server. Also, I heard nginx may be able to do it. I want like following example

Localhost:3000 -> www.domain.com
Localhost:3001 ->subdomain.domain.com
Localhost:3002 -> www.anotherdomain.com

How can i do it with it in the linux environment? Please guide me using suitable examples.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Assuming you've already installed Nginx (apt install Nginx).

Just create a separate virtual host file per each server.

For example, it can be like this for www.domain.com

/etc/nginx/sites-enabled/domain.com.conf
server {
        listen 80;
        server_name www.domain.com;

        
        location / {
          proxy_pass localhost:3000;
        }
}

and like this for subdomain.domain.com

/etc/nginx/sites-enabled/subdomain.domain.com.conf
server {
        listen 80;
        server_name subdomain.domain.com;

        
        location / {
          proxy_pass localhost:3001;
        }
}

I'm avoiding such things as SSL, root file, etc as this can be found elsewhere.

https://hackprogramming.com/how-to-setup-subdomain-or-host-multiple-domains-using-nginx-in-linux-server/

Don't forget to test nginx sudo nginx -t and restart it to pick up changes (sudo service nginx restart)

over 4 years ago · Santiago Trujillo Relatório

0

  1. Firstly, install NGINX https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/.
  2. Edit the config file of nginx in the path like /etc/nginx/

It is good for you to learn editing the config file first. https://docs.nginx.com/nginx/admin-guide/web-server/web-server/

  1. Here are some examples:
server {
    listen 80;
    server_name www.domain.com;

    location / {
        proxy_pass http://Localhost:3000;
    }
}

server {
    listen 80;
    server_name subdomain.domain.com;

    location / {
        proxy_pass http://Localhost:3001;
    }
}

server {
    listen 80;
    server_name www.anotherdomain.com;

    location / {
        proxy_pass http://Localhost:3002;
    }
}

When you use domains to visit your page, the configuration above may help you. Whats more you should specify one server as your default server when you visit with ip address.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda