How to redirect users who try to hit App Service link directly to a domain

Anonymous
2024-10-21T22:19:23.5833333+00:00

Hi,

Currently we have an App Service with no inbound restrictions. We want to enforce inbound restriction so that users will have to use the domains setup and access will happen from AFD. If we do that we will get the below error for users who directly hit the App service URL. Instead, we want to redirect them to the domains we have setup. Users will see this error screen and get confused. Is there any possible way to accomplish this redirection?

Screenshot shows the text of Error 403 - Forbidden.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
{count} votes

1 answer

Sort by: Most helpful
  1. Deepanshu katara 18,140 Reputation points MVP Moderator
    2024-10-22T07:21:52.4733333+00:00

    Hello , Welcome to MS Q&A

    To enforce inbound restrictions on Azure App Service and redirect users who directly hit the App Service URL to the setup domains, you can follow these steps:

    Set Up Access Restrictions: - Configure access restriction rules that allow or deny traffic based on IP addresses or Azure Virtual Network subnets. This can be done by setting up a priority-ordered allow/deny list that controls network access to your app. If a request does not match any rules, it will receive an HTTP 403 status code.

    Implement URL Redirection: - You can implement URL redirection within your application code or use Azure Application Gateway. By configuring the Application Gateway to restrict access, you can ensure that only traffic from specific sources is allowed, effectively redirecting unwanted traffic.

    References:

    Kindly accept answer if it helps

    Please let us know if further questions

    Thanks

    Deepanshu


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.