Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda