6

I have nginx proxy and I want all requests to be proxied to another server with the same uri.

Here's what I did:

location / {
    proxy_pass https://example.com;
}

But I need one exception in this rule - when url is empty (user visits actual / location) I want to proxy this request to https://example.com/index

How do I write a rule for an empty url?

1
  • AFAIK / is the "no URL" request. I suspect you need to use try_files.
    – Tim
    Mar 4, 2016 at 19:23

1 Answer 1

9

I guess, you mean / location as this is the “minimal” location. You could use “exact match” (=) modifier:

location / {
    proxy_pass https://example.com;
}

location = / {
    proxy_pass https://example.com/index;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .