How to Capture Fiddler Trace in Linux Container (For APIM Self-hosted Gateway)
Published Nov 11 2020 12:10 AM 4,272 Views

In certain conditions, we may need to monitor all HTTP/HTTPS traffic from APIM self-hosted gateway, which is deployed into Linux Docker Container.


Capturing Fiddler trace is one of the available options. However, there are limitations:

  1. APIM self-hosted gateway image is built by Azure APIM product group and we cannot build the Fiddler tool into the container image.
  2. APIM self-hosted gateway is a Linux container. Fiddler Classic only works in Windows environment.

The instructions below guide you how to bypass the limitations and capture Fiddler trace in Linux containers (for APIM self-hosted gateway).



Before starting, you must setup the environment at first.   

To set up a local development environment, you need to have:  

  1. API Management instance. If you don't have one, please follow this tutorial.  
  2. Deploy an Azure API Management self-hosted gateway to Docker. If you don't have one, please follow this tutorial.
  3. Install Fiddler Classic into your local computer. To download Fiddler Classic, please click this link


Steps to implement: 

  1. 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).





  1. Go to HTTPS and DISABLE Decrypt HTTPS traffic.



  1. Open CMD on the start menu. Check your local IP with the command ipconfig. My IP is as shown in the screenshot below.



  1. 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.Lucy_Weng_4-1605080047507.png


  2. Deploy the Docker container by following this tutorial. Please use the modified file env.conf in step 4.


  1. 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.



  1. 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.



  1. Copy the root certificate to the docker container by using the following command:
  • docker cp C:\Users\your-user-name\Desktop\FiddlerRoot.cer your-container-id:/home/fiddlerPublicCert.cer
  1. 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
  1. Update the CA certificates to enable the fiddler root cert by the following command:
  • update-ca-certificates



  1. Go back to Fiddler. Open Options => HTTPS. Enable Decrypt HTTPS traffic.



  1. 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.





1 Comment
Version history
Last update:
‎Mar 10 2021 07:09 PM
Updated by: