Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

353
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!