<p>Basically we have a set of microservices we have deployed to a kubernetes cluster hosted in AWS. We would like to run these through a gateway configuration in nginx. </p>

<p>Our current configuration which doesn't work looks something like this-</p>

<pre><code>upstream some-api1 {
    server some-api1:80;
}

upstream some-api2 {
    server some-api2:80;
}

upstream some-api3 {
    server some-api3:80;
}

server {
    listen 80;
    server_name gateway.something.com;
    location /api1 {
        proxy_pass  http://some-api1;
    }
    location /api2 {
        proxy_pass  http://some-api2;
    }
    location /api3 {
        proxy_pass  http://some-api3;
    }
}
</code></pre>

<p>Our services have been built with dotnet core, so the underlying urls would be something like <a href="http://some-api1/" rel="nofollow noreferrer">http://some-api1/</a>{api/controllername} . I'm always getting a 404 when I try hitting these endpoints through postman, which tells me it can't resolve these mappings.</p>

<p>However I'm able to access an api within the cluster using an explicit config for an api like so(which is what I don't want to do)-</p>

<pre><code>server {
    listen 80;
    server_name someapi1.something.com;
    location /{
        proxy_pass http://some-api1;
    }   
}..
</code></pre>

<p>If someone could shed some light on what's wrong with the configuration or recommend the best approach for this it would be greatly appreciated.</p>

Brandon
<p>As @Luminance suggests, you're seeing traffic to /api1 go to some-api1/api1 instead of just some-api1 on the base path for that target service (which is what your app would respond to). Following <a href="https://gist.github.com/soheilhy/8b94347ff8336d971ad0" rel="nofollow noreferrer">https://gist.github.com/soheilhy/8b94347ff8336d971ad0</a> you could re-write that target like</p>

<pre><code>location /api1 {
       rewrite ^/api1(.*) /$1 break;
       proxy_pass http://some-api1;
    }
</code></pre>
