Azure Front Door with Azure Application gateway - azure

I am trying to setup an architecture where I have a static website stored on Azure storage and an App Container that serves the API. I would like to serve both from the same domain, but with a different path. The static site will be on the root path and the API will be on the /api path. I am writing an extension for an existing website and this URL setup is a requirement from it.
To achieve this result, I have an application gateway that can direct the requests based on the path (this already works), but so far it only has a public IP address.
I also have a Front Door with a custom origin to the application gateway. The Front Door received a domain name from azure and it is fine for now.
My issues is that when I access the Front Door on https, it tries to access the App GW with https, but obviously it doesn't support it, since it only has an IP address and I didn't create an SSL certificate for it.
Now, I am stuck, because I cannot configure the Front Door for SSL offloading, but I also cannot configure APP GW to accept https connections.
Does anybody knows the right setup for this case?

• You want to configure the application gateway to accept HTTPS connections when you are accessing the front door on HTTPS and it doesn’t support the SSL offloading and you are not able to redirect the same requests over HTTPS to the application gateway. Thus, in this scenario, to achieve this, you will have to add a NSG (Network Security Group) and link the Application Gateway subnet configured to it.
This will ensure that though the HTTPS connection requests are incoming through the Front door, they will be routed correctly to the application gateway’s public IP address via the NSG rules in place as shown below: -
Ensure that all the other rules are not present in your NSG that is associated with the application gateway and only the highlighted ones are created and mentioned so that when the requests are received on the Azure front door over HTTPS, the request is routed through the NSG via above created inbound rules and forwarded as SSL HTTPS request over the said associated private IP address created in the virtual network.
Please find the rules as below: -
Source: Service Tag
Source service tag: AzureFrontDoor.Backend
Source Port ranges: *
Destination: Any
Destination port ranges: *
Protocol: Any
Action: Allow
Priority: 200
Source: Service Tag
Source service tag: GatewayManager
Source Port ranges: *
Destination: Any
Destination port ranges: 65200-65535
Protocol: Any
Action: Allow
Priority: 300
Source: Service Tag
Source service tag: VirtualNetwork
Source Port ranges: *
Destination: Any
Destination port ranges: *
Protocol: Any
Action: Allow
Priority: 400
Source: Service Tag
Source service tag: AzureLoadBalancer
Source Port ranges: *
Destination: Any
Destination port ranges: *
Protocol: Any
Action: Allow
Priority: 500
Source: Any
Source Port ranges: *
Destination: Any
Destination port ranges: *
Protocol: Any
Action: Deny
Priority: 600
Once done, the application gateway accepts HTTPS requests from the Azure front door over Port 443 after configuring the custom domain on it.
For more information, kindly refer to the below links: -
Azure Front Door in the front of Application Gateway
https://learn.microsoft.com/en-us/azure/frontdoor/front-door-faq#when-should-we-deploy-an-application-gateway-behind-front-door-

Related

Block port 80 access in Azure Front door

I created a Standard tier Front Door with the necessary Azure WAF with default configurations. If I do this:
Test-NetConnection -ComputerName "<frontdoorurl>-dev-xxxxxx.z01.azurefd.net" -Port 80
ComputerName : <frontdoorurl>-dev-xxxxxx.z01.azurefd.net
RemoteAddress : xxxx:xxx:xx:x::xx
RemotePort : 80
InterfaceAlias : Ethernet 7
SourceAddress : xxxx:xxxx:xx:xxx:xxxx:xxxx:xxx:xxxx
TcpTestSucceeded : True
I am unable to block this permanently - I tried having a rule set on the Server port equal to 80 conditions but there is no suitable action for this that blocks the port 80 access throughout.
How to block this permanently so that the result of Test-NetConnection is False? or is there no way to block the access to port 80 from outside?
P.S. I have tried asking ChatGPT - it tells me to use Network Security Group and block port 80. But in the latest Azure Portal setting for Front Door - no such provision is made.
Azure Front Door will allow https requests by default, but you can restrict the http request for each end point using Routing Rules.
NOTE: With the front door URL, Test-NetConnection will not return a false result because FD will try to fetch the service responses frequently and, if they are not reachable, will send a message such as "Services are down."
Here is the way to restrict port 80 from Front Door.
Step1:
Create front door application with 2 backend pools and Configure routing rule as follows.
Step2:
update route rule with https & https request allows both allow
Verificaiton:
when browse the URL it will allow both http and https calls
Step3:
Now, in order to restrict the http [80] port in the backend, update the routing rule to https only.
Step4:
Save the Front Door settings
Step5:
now https [443] port only allow to access the application and 80 port it won't allow via front door URL.
Note:
We need to restrict port 80 from both the application endpoint side and the server side. Otherwise, when we ping from Test-NetConnection, it will return a true value. Because Front Door will give the response that the site is not reachable
Backend Pool like this
becuase of this configure
Azure Front Door consists of a a distributed network of POPs (Points-of-Presence) and these are listening for both port 80 and 443 on an Anycast IP, meaning you'll just get routed to whatever POP is closest to you. Your AFD endpoint will resolve to one of these Anycast IP's. You cannot block port 80 because these POPs handle more than just your site. There are numerous other customers that have sites hosted on these POPs and some are accepting HTTP, so port 80 is open. It's also needed for HTTP to HTTPS redirection. With respect to a TCP connection, the domain name is irrelevant as we aren't at the HTTP layer yet.
You can always redirect traffic from HTTP to HTTPS but these POPs are not in your control, unlike something like Application Gateway. With App Gateway, you can listen for whatever ports you want because it's not shared with other customers.

my NSG has default rule to allow traffic from AzureLoadBalancer (inbound) but it still not allowing traffic from AzureLB to backend pool servers

I have a subnet (10.0.2.0/16), it has two web servers web2(10.0.2.6) and web3(10.0.2.7) having IIS installed in it. I have created a Azure LB and added these two web servers as back end pool, crated two health check probes and two loadbalance rules for the ports (80 & 443).
When I tried to access web page by Public IP of LB it is denied though we have default rule in NSG to allow inbound traffic from Azure load balancer.
Next I have created two more rules (with high priority than default rules) by use Service tag as source and selected AzureLoadbalancer and destination as Any and ports 80 & 443. Still I can't access webpage thru LB Public IP.
Again I have deleted newly created rules added new rules ANY as source and destination and selected ports 80 & 443, now I can access web page thru LB public IP.
What wrong in default rules, and rule created with service tag as AzureLoadbalancer.
Image of the rules

How to add a subdomain in cloudflare for my azure container which requires a port number to access it

I have a metabase docker image running on my Azure container. It can be accessed through azure's fqdn:port_number (port is 3000) or ip:port_number. I want to give a nice domain name for this application through cloudflare(. How can I do this?
Thanks in Advance!
PS: There were some topics on this in cloudflare community but I couldn't fine any answer relevant for me.
You could add a CNAME record to point subdomain such as www.example.com to the FQDN value of your Azure container like containerdns.westus.azurecontainer.io.
Example of a CNAME record:
name: www
record type: CNAME
value: FQDN value of your Azure container
TTL: 32600
ref: https://www.cloudflare.com/learning/dns/dns-records/dns-cname-record/
https://support.cloudflare.com/hc/en-us/articles/360019093151-
Update
From your comment, you want to access myapp.com which actually points to fqdn:port. In this case, you could create and configure an application gateway to host web sites with custom ports using the Azure portal. If you have multiple sites, you could follow this tutorial.
You could follow the steps below:
Create a public-facing application gateway with a public IP address in the same region as your container instance.
Create a backend pool with target hostname of your container FQDN like containerdns.westus.azurecontainer.io
Create a basic listener and provide name, frontend port 80 and protocol HTTP.
Create a health probe, provide protocol HTTP, check the box Pick host name from backend http settings and the remaining setting is the default.
Add an HTTP-settings with custom port 3000 as your desired and check the box Pick host name from backend address and use custom probe and select custom probe.
Create a basic rule with the backend pool and HTTP setting.
In the end, you could create a CNAME record mapping the subdomain www.myapp.com to the FQDN of your application gateway.
I validate this on my website on Azure VM, hope this could help you.

New Azure Standard LB doesn't allow inbound connection

I have setup a LB with a backend pool (only one host for test). I setup network security group on test host with following rule:
Source: AzureLoadBalancer Destination: Any Action: Allow
Source: VirtualNetwork Destination: VirtualNetwork Action: Allow
Source: Any Destination: Any Action: Deny
I can't connect to host through LB (from host in the same VNET).
It's a public LB and I try to connect through ip public.
If I setup a rule Source: Any Destination: Any Action: Allow
All work fine.
Of course, I don't want this rule.
What's wrong with my setup ?
Thanks.
You need to add an inbound port rule to allow connections from remote location to virtual machines. Find the network security group associated with the host Vnet. Add the inbound port (rdp 3389, ssh 22 or other port your self-defining ) which you allow to connect the host. Additionally, you will give every rule a priority. Low number of priority means high priority.
For more information about create a public Basic load balancer by using the Azure portal.

Create HTTPS endpoint for Azure Virtual Machine

I have created a virtual machine in Azure and enabled the IIS role.
I have created the appropriate firewall rules to allow me to browse to a website that I have set up in IIS over HTTP.
However, despite having created the bindings and firewall rules to enable HTTPS, I am unable to browse to the same website over HTTP.
I have been reading that I need to create a HTTPS endpoint for Azure to traffic any requests on port 443 to my site.
Does anyone know how to do this in the new portal?
Thanks,
Sean
By default, when you create a VM, only port 3389 (RDP) is opened. You will need to add any additional ports that you need to the Network Security Group.
Here is an example of how to add an NSG inbound rule to allow traffic on port 80 (HTTP), but you can use the same steps to allow traffic on port 443 (HTTPS):
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/nsg-quickstart-portal
Ok, so I have got this working so I will document the steps that I went through in order to get this to work:
Create a public IP address in the Azure portal
Assign a ‘cloudapp.azure.com’ DNS name to the IP address
Associate the IP address to an Azure network interface (this network interface may be attached to a VM or an App Service – in our case, it’s a VM)
Create an http endpoint in IIS and set the host name in your bindings to the ‘cloudapp.azure.com’ DNS name and the the IP address to the IP address created in step 1
Create a https endpoint and select your wildcard server certificate as the SSL certificate
Create a ‘CNAME Record’ entry in your DNS Configuration where the host is your custom DNS name and the target is the Azure DNS name
Open a web browser and browse to your custom DNS name via https and ensure that the website displays the server certificate

Resources