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

146
Visualizações
How to deploy multiple reactjs applications with nginx?

I'm trying to deploy multiple projects on same path.

I'm working with a virtualbox using ubuntu. I've created a folder called multiprojects and inside there are 3 folders with one project inside eachone: demo, project1 and project2.

  • demo folder contains all files builded after call npm run build on demo project.

  • project1 folder contains a folder, with name build, that contains all files buided after call npm run build on project1.

  • project2 folder contains a folder, with name build, that contains all files buided after call npm run build on project2.

Also, project1 contains "homepage" in package.json that redirect to project1. "homepage": "/project1". project2 contains "homepage" in package.json that redirect to project2. "homepage": "/project2" and demo project doesnt contains homepage in pacakage.json

Each projeact has in App.js is own public path:

For example, in demo project has as a publicPath /demo, in project1 /project1 and finally in project2 /project2

const publicPath = "/demo";

return (
    translations &&
    styles && (
        <BrowserRouter basename={publicPath}>
            <ToastProvider>
                <IntlProvider
                    key={settings.locale}
                    locale={settings.locale}
                    defaultLocale="en"
                    messages={translations[settings.locale]}
                >
                    <Routes />
                </IntlProvider>
            </ToastProvider>
        </BrowserRouter>
    )

And this is my nginx config:

server {
    listen  8090;
    server_name localhost;
    index index.html index.htm;

        location /project1 {
            root /home/osboxes/Documents/multiproject/project1/build;
            try_files $uri $uri/ /index.html;
        }

        location /project2 {
            root /home/osboxes/Documents/multiproject/project2/build;
            try_files $uri $uri/ /index.html;
        }

        location / {
            root /home/osboxes/Documents/multiproject/demo;
            try_files $uri $uri/ /index.html;
        }
    }

I have two questions:

  • How can I do it better?
  • How can do this in a docker file?
over 4 years ago · Santiago Trujillo
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