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

362
Visualizações
NGINX redirect https to https + /location getting loop redirect

I am trying to deploy my angular app with a nginx server. The problem that i have is when i access to the website i need to be redirected to a specific location, in this case i need to be redirected to mydomain.com/shop, when i enter to this site it gets in a loop and start to type mydomain.com//shop/shop/shop/shop/shop......

Here is my code.

  server {
    listen 443 ssl;

    ssl_certificate C:/nginx/ssl/cc.crt;
    ssl_certificate_key C:/nginx/ssl/pkc.key;

    server_name  mydomain.com www.mydomain.com;
    return 301 https://$host$request_uri/shop;
} 

server {
    listen       443 ssl;

    client_max_body_size 200M;

    ssl_certificate C:/nginx/ssl/cc.crt;
    ssl_certificate_key C:/nginx/ssl/pkc.key;

    server_name  mydomain.com www.mydomain.com;

    location / {
        root   html/myApp;       
        try_files $uri $uri/ /index.html;
    }

    location /api/ {
        client_max_body_size 200M;
        
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass https://127.0.0.1:4000/;
        proxy_redirect off;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

how can i fix it? Thanks in advance

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

0

You have two server blocks with the same listen and server_name. The second block is being ignored as a duplicate.

You need to delete that first server block and place a redirection rule into the second block.

For example:

location = / { 
    return 301 /shop; 
}
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