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

150
Visualizações
Nginx two angular apps

I'd like to add separated angular app under a specific path (the path should be at the end of an URL to be matched) - I want to keep both versions which are current and a new one but the new should only be available under the specified path. I tried using alias + try_files. My config:

server {
  listen 80;
  root /dir/project1
  server_name ...;

  index index.html;

  location ~ /path {
    alias /dir/project2
    try_files $uri $uri/ /index.html;
  }

The thing is that when try_files fires up, it takes the path from the root directive - not from the alias. How to fix it? I can only add I cannot use proxy_pass here and root instead of the alias does not work either as it adds paths etc.

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

0

The alias directive works differently when placed inside a regular expression location, but you should probably be using a prefix location anyway. See this document for details.

Also, the use of alias and try_files together can cause problems (see this long standing bug).

You are rewriting the URI to /index.html which is the wrong application, and should instead be /path/index.html.

Try:

location ^~ /path {
    alias /dir/project2;
    if (!-e $request_filename) {
        rewrite ^ /path/index.html last;
    }
}

See this caution on the use of if.

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