azureazure-web-app-serviceazure-virtual-networkazure-private-linkazure-private-dns

Frontend app service calling a backend app service in a VNet with private endpoint returns 403 IP forbidden error


I'm trying to secure an application, deployed in Azure, consisting of an Angular frontend and a Node (Nest.js) backend. I want the frontend to be accessible via the internet unlike the backend which should only be accessible from the frontend (without being accessible via the internet). The backend seems to restrict access by taking the client's IP instead of the frontend's IP which causes a 403 IP Forbidden error.

In summary (version with path to Bicep file below)

To do this, I created:

And I made the following configuration:

Results

On my frontend, I make an HTTP request to my backend API. The backend responds to me ERR_FAILED 403 (Ip Forbidden). In the response headers, I see "x-ms-forbidden-ip: xxx.xxx.xx.xx" (the public ip of my company's network that my PC is on). See here. Shouldn't I see my frontend App Service IP?

For Information, if in App Service backend > Networking > Access restriction, I add a rule authorizing the public IP of my company, the request returns me a code 200 and no longer 403.

How do I block public access to the backend but still manage to perform requests from the frontend? (After many research, I haven't found any successful answers to solve this yet).

Version with Bicep file

I followed this tutorial. At the end of the article, a Bicep file is available.

So I did the following:


Solution

  • From what I see you have your Azure environment set up correctly. I suspect the code in your Angular frontend is asking your web browser to make direct calls to the backend. You probably want your browser to make calls to the front end, which will then be routed or passed on to the back end.

    You can confirm the current behavior by running Wireshark on the machine you're using your browser to access the website. You'll see traffic going to your backend IPs.