Deploy an Azure API Management self-hosted gateway to Docker. If you don't have one, please follow this tutorial.
Install Fiddler Classic into your local computer. To download Fiddler Classic, please click this link.
Steps to implement:
Open Fiddler. Go to Options… => Connections, select Allow remote computes to connect. In the screenshot below, Fiddler listens on port 8888. Then Fiddler will capture traffic from another machine (any OS).
Go to HTTPS and DISABLE Decrypt HTTPS traffic.
Open CMD on the start menu. Check your local IP with the command ipconfig. My IP is 100.64.77.231 as shown in the screenshot below.
Open the file env.conf for the APIM self-hosted gateway. Specify the HTTP/HTTPS proxy here. Fiddler by default listens the port 8888, as discussed in the Step One.
Use command "docker exec your-container-id env" to check if HTTP/HTTPS proxy is enabled as environment variables within the docker container. As shown in the screenshot below, the traffic is flowed into the Fiddler, but the HTTPS requests are still encrypted.
If we need to decrypt the HTTPS traffic, we need to install Fiddler root certificate into the container CA certificate list. Go back to Fiddler. Open Options => HTTPS => Actions. Select Export Root Certificate to Desktop. The certificate name should be FiddlerRoot.cer by default.
Copy the root certificate to the docker container by using the following command:
As update CA certificates in the Docker container needs the admin permission, we can exec into the Docker container in iterative mode by using the following command:
docker exec -u root -it your-container-id /bin/sh
Update the CA certificates to enable the fiddler root cert by the following command:
Go back to Fiddler. Open Options => HTTPS. Enable Decrypt HTTPS traffic.
To test if Fiddler can capture the requests in Docker container, we can send the simple requests to the APIM self-hosted gateway via CURL. In the tests below, I sent two HEAD requests to the self-hosted gateway and Fiddler successfully capture both.