<p>I am using azure kubernetes for backend deployment. I have 2 URLs one is API URL(api.project.com) and other one is BFF URL(bff.project.com).</p>
<p>From Web application, instead of calling API URL(api.project.com) they use BFF URL(bff.project.com) which internally calls the API URL(api.project.com) and sends the response.</p>
<p>I now want to restrict direct usage of API URL(api.project.com) even from any REST API Clients(like postman, insomnia, ...) it should only work when triggered from BFF URL(bff.project.com).</p>
<p>We have used nginx-ingress for subdomain creation and both the URLs(BFF and API) are in same cluster.</p>
<p>Is there any firewall or inbuilt azure services to resolve the above mentioned problem ?</p>
<p>Thanks in Advance :)</p>

<p>You want to keep your api private, only accessible from another K8S service, so don't expose it using your ingress controller and it simply won't be accessible outside K8S to any client.</p>
<p>This means that you lose the api.project.com address (although you can get that back if you really want to, it seems unnecessary). The BFF would then access the API via the URL: <code>http://&lt;service-name&gt;.&lt;namespace&gt;.svc.cluster.local:&lt;service-port&gt;</code>, which in your case might be:</p>
<pre><code>http://api.api_ns.svc.cluster.local
</code></pre>
<p>Assuming you haven't used TLS (http rather than https), the service is called <code>api</code>, it's running on port 80 (which it should be) and the namespace is called <code>api_ns</code>.</p>
<p>Should you need to provide temporary access to the API for developers to use, say, postman, then they can use port-forwarding to provide that in a dev environment without allowing external access all the time.</p>
<p>However, this won't restrict access to BFF alone. Any service running in K8S could access the API. If you need/want to restrict things further, then you have a lot of options.</p>
