feat: Restrict backend API to private access in WAF deployment#173
Open
Prajwal-Microsoft wants to merge 2 commits intodevfrom
Open
feat: Restrict backend API to private access in WAF deployment#173Prajwal-Microsoft wants to merge 2 commits intodevfrom
Prajwal-Microsoft wants to merge 2 commits intodevfrom
Conversation
When enablePrivateNetworking (WAF mode) is active: - Add privatelink.azurewebsites.net private DNS zone linked to VNet - Create private endpoint for backend API App Service in backend subnet - Set publicNetworkAccess to Disabled for backend API - Frontend nginx reverse-proxies /api/ requests to backend over VNet - VITE_API_BASE_URL set to empty string so SPA calls same origin - BACKEND_API_URL env var drives dynamic nginx proxy config at startup - Non-WAF deployments remain unchanged (direct public API access) Resolves US#39249 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When VITE_API_BASE_URL is empty string, the React app's getApiBaseUrl() treats it as falsy and defaults to http://localhost:8000. Fix by setting it to window.location.origin (a JS expression) in the runtime config when in WAF/private networking mode, so the SPA correctly calls its own origin where nginx proxies /api/ to the private backend. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
When
enablePrivateNetworking(WAF mode) is active, the backend API App Service (api-{suffix}) was still publicly accessible on the internet. This PR restricts the backend API to private-only access while keeping the frontend Web App publicly reachable — aligning with the WAF security posture.Changes
Infrastructure (
infra/main.bicep&infra/main_custom.bicep):privatelink.azurewebsites.netprivate DNS zone linked to VNetbackendsubnetpublicNetworkAccess: 'Disabled'for the backend API whenenablePrivateNetworking=trueVITE_API_BASE_URLto empty (same-origin) and passesBACKEND_API_URLfor the nginx proxyFrontend (
src/App/):nginx.conf: Addedincludefor dynamically generated API proxy configstartup.sh: Generates nginx reverse proxy config at container startup — proxies/api/*to backend over VNet using Azure DNS resolver (168.63.129.16). SetsVITE_API_BASE_URLtowindow.location.originin WAF mode so the SPA correctly calls its own originDockerfile: Creates empty placeholderapi-proxy.confduring buildArchitecture (WAF mode)
Non-WAF deployments are unchanged — direct public API access continues as before.
Resolves AB#39249
Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
403 Ip Forbiddenfrom public internet in WAF deploymentOther Information
168.63.129.16for private DNS resolution andproxy_ssl_server_name onfor SNI