1

I am trying to set proxy_pass based on $host value, I tried this:

location /api/v1/ {
    if ($host = .*\.npreprod.company.com)
    {
            proxy_pass https://frontend-api.preprod.company.com/api/v1/;
    }
}

however, I got the error

nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in /etc/nginx/sites-enabled/nuxtjs.conf:45

so, what's the proper way to achieve this?

Gerald Schneider
  • 26,582
  • 8
  • 65
  • 97
simo
  • 170

0 Answers0