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

356
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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