Block port 80 access in Azure Front door - azure

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.

Related

Azure traffic direction explanation

I am really not clear what outbound(egress) and inbound(ingress) traffic means. I have two theories
inbound just specifies that the origin is outside and target inside i.e. HTTP round trip to some VM hosted web is ingress, the response with HTTP 200 status goes the same established route back
inbound is anything from internet and outbound is anything to internet. So HTTP roundtrip to azure VM is ingress and also egress (HTTP response), both of which can have different route(in case of asymmetric routing.
My question is if the VM does not have route back to internet, will it serve properly the HTTP or the response cannot reach the originator in internet?
Inbound traffic originates from outside the network, while outbound
traffic originates inside the network.
My question is if the VM does not have route back to internet, will it serve properly the HTTP or the response cannot reach the originator in internet?
Assuming you have a web server running on it, you just need to configure on firewall rules to enable inbound / outbound traffic for port 80 and 443

AWS Application load balancer throwing 502

I am currently learning about AWS and I have a single EC2 instance running with a nodejs server on port 3000, an Application load balancer with SSL setup that listen on port 80 and 443 (http & https). When I make requests to the http route it returns back the successful health check message. But when I try to access my api via the https method, I get a 502 Error. I googled around and read some articles and they pointed out that the nodejs server keepAliveTimeout and headersTimeout should be higher than the timeout option of the ALB. I tried that and it didn't work. I also tried to set the max-http-header-value to 16384, I also tried to check the access logs for the load balancer on my S3 bucket and the logs just showed that I am getting a 502 error and nothing more. What could be the issue? Because I have tried all solutions that presented but they don't seem to work.
The 443 listener needs to be pointed to port 80 on the ec2 instance
The first thing to check is that your server is responding to requests. Try connecting to port 3000 on the server, either from the server itself (eg curl localhost:3000) or from outside the server (which will require the Security Group to permit access to port 3000).
Once you have confirm that the server is responding, configure Security Groups as:
A Security Group on the Application Load Balancer (ALB-SG) that permits Inbound access on ports 80 and 443
A Security Group on the Amazon EC2 instance (App-SG) that permits inbound access on port 3000 from ALB-SG
That is, App-SG should specifically refer to ALB-SG in its Inbound rules.
Then, configure the Load Balancer to have a Target Group that points at port 3000 on the app server and provide it a URL for the Health Check (that could simply be /).
Then, connect to the Application Load Balancer and see whether you can access your app.

Using HTTPListener with Azure Web apps

I'm trying to get a simple HTTP console app running as an Azure Service App. All it does is return OK when you connect. It works fine on my laptop and I can publish to Azure ok using VS2019. The issue is the prefixes that are used for listening.
On my laptop I can use http://+:80/;https://+:443/, but in Azure I get an error: [EXCEPTION] Access is denied.
This article https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#network-endpoint-listening implies the app will listen on 80 and 443
"The only way an application can be accessed via the internet is through the already-exposed HTTP (80) and HTTPS (443) TCP ports; applications may not listen on other ports for packets arriving from the internet.
However, applications may create a socket which can listen for connections from within the sandbox. For example, two processes within the same app may communicate with one another via TCP sockets; connection attempts incoming from outside the sandbox, albeit they be on the same machine, will fail. See the next topic for additional detail."
but my code always fails when I try and register the prefix. I can't use localhost as the same article says that's not allowed. I've tried using the app URL but that doesn't work either.
I've seen other articles that imply the HTTPListener needs admin permissions which I can't give it in Azure.
Does anyone know what the correct prefixes are or if it's ever going to work?
Netstat not working in KUDU so ASE (App Service Environment) is used to view the port details in portal App Service Environment -> General -> IP Addresses (check here ).
App Service applications only serve HTTP (port 80) and HTTPS (port 443) traffic. Each App Service application has default built-in HTTPS support for the azurewebsites.net domain name.
Your app may be already listening to the port 80 & 443. Please check here for more info for similar issue see here

Azure: Route subdomain traffic to different backend port

I have multiple sites hosted on the same machine in Azure on different ports:
foobar.com:8000
foobar.com:8001
foobar.com:8002
etc
I would like to address these by subdomain using a reverse proxy;
aaaa.mysite.com ----> foobar.com:8000
bbbb.mysite.com ----> foobar.com:8001
cccc.mysite.com ----> foobar.com:8002
Is it possible to do this in Application Gateway? It only seems to cater for different paths (not subdomains) and doesn't allow ports to be specified for backends.
Is there another Azure feature that allows for this (e.g. Front Door)?
As your requirement to address them by subdomains in APP GW, you could use multi-site hosting.
There are three common mechanisms for enabling multiple site hosting
on the same infrastructure.
Host multiple web applications each on a unique IP address. Use host
name to host multiple web applications on the same IP address. Use
different ports to host multiple web applications on the same IP
address.
For example, you want aaaa.mysite.com ----> foobar.com:8000. The main configuration will be like this: create a multi-site listener, use frontend port 80 and hostname aaaa.mysite.com in this multi-site listener. HTTP setting should specify the port 8000. Make sure the listener is listening on port 80 and HTTP setting configure your custom port for your backend websites.
In this case, you will create 3 Listeners with on same port 80,and specify the hostnames and create 3 HTTP settings, and create rules with corresponding Listener and HTTP settings and backend pool.
The Azure front door also has URL-based routing and Multiple-site hosting ability. Refer to this document.
Update
Backend pools
Create one backend pool and set your Azure VM as the backend in the backend pool.
Listeners
Click multi-site to create a multi-site listener then save it. You need three listeners for your host name.
Type the subdomains as the host name
Health probes
Add a health probe and checkbox pick host name from backend http settings.
HTTP settings
Add three HTTP settings and specify the custom port on each of HTTP settings.
Rules
Add three basic rules with corresponding Listener and HTTP settings and backend pool.

How to route all traffic to a single port on google compute engine

I'm hosting a node app on the google compute engine. My app is set to listen to the port 8080. I opened up a firewall to allow tcp connections to port 8080. I can connect to my app by entering
http://<your-instance-ip>:8080
in the google chrome browser, where your-instance-ip is the external ip of the compute engine instance. I bought a domain. I want to make it so that when you enter my domain, it redirects you to this specific port. But you can only add the external ip in the A-record of my godaddy domain. How do I route all traffic to that ip, to the specific port 8080? I used nodejs with express. I want to do this using NGINX, could someone point out some tutorials?
Click on 'default' Network and Edit your "default-allow-http", make sure existing "Allowed protocols and ports" is "tcp:80" and target-tag is "http-server" also add "nodejs" in target-tag. Save your changes. Restart your google console. godaddy will listen the port 80

Resources