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

331
Views
Nginx accept trailing slash or no trailing slash in proxy_pass

I'm running into the following issue where I would like to be able to access a proxy passed location (React/NextJs webApp in a hosted docker container) from a home website with a trailing slash and without a trailing slash.

Currently, when I hit:

http://my-website.com/test # this works

But when I hit:

http://my-website.com/test/ # this fails with a 404

I'd like to be able to hit both of these urls. What am I missing?

   ### Default Server ###
    server {
        listen 80;
        root /usr/site;
        if ($http_x_forwarded_proto = "http") {
            return 301 https://$host$request_uri;
        }
        location ~/test(.*)$ {
                set $upstream_endpoint http://$docker_container_url;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_pass $upstream_endpoint$1/;
                proxy_set_header    Host    $host;
                proxy_cache_bypass  $http_upgrade;
        }
    }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

After long experiments we came to this solution:

  location ~ ^/test(?:/(.*))?$ {
    # some directives here
    proxy_pass http://nginx_docker_container_url/$1;
    # some directives here
  }

needed to pass everything after /test to app, with or without trailing slash it should be handled correctly

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!