How do I monitor all incoming http requests?

后端 未结 9 842
南方客
南方客 2020-12-07 09:01

I need to monitor my application from incoming http POST and GET requests originating from outside and sometimes inside the machine.

Is th

相关标签:
9条回答
  • 2020-12-07 09:29

    You might consider running Fiddler as a reverse proxy, you should be able to get clients to connect to Fiddler's address and then forward the requests from Fiddler to your application.

    This will require either a bit of port manipulation or client config, depending on what's easier based on your requirements.

    Details of how to do it are here: http://www.fiddler2.com/Fiddler/Help/ReverseProxy.asp

    0 讨论(0)
  • 2020-12-07 09:33

    Configure Fiddler as a 'reverse proxy' on Windows

    (for Mac, see the link in Partizano's comment below)

    I know there's already an answer suggesting this, however I want to provide the explanation and instructions for this that Telerik should have provided, and also cover some of the 'gotchas', so here goes:

    What does it mean to configure Fiddler as a 'reverse proxy'?

    • By default, Fiddler only monitors outgoing requests from the machine on which you're running Fiddler
    • To monitor incoming requests, you need to configure Fiddler to work as a 'reverse proxy'
    • What this means is that you need to set Fiddler up as a 'proxy' that will intercept incoming http requests that are sent to a specific port (8888) on the machine where you want to listen to the incoming requests. Fiddler will then forward those requests to the web server on the same machine by sending them to the usual port for http requests (usually port 80 or 443 for https). It's actually very quick and easy to do!
    • The standard way to set this up with Fiddler is to get Fiddler to intercept all request sent to Port '8888' (since this won't normally be used by anything else, although you could just as easily use another port)
    • You then need to use the registry editor to get Fiddler to forward any http requests that Fiddler receives on port 8888, so that they're forwarded to the standard http port (port 80, port 443 for an https request, or another custom port that your web server is set to listen on)

    NOTE: For this to work, any request you want to intercept must be sent to port 8888

    You do this by appending :8888 to your hostname, for example like this for an MVC route:

    http://myhostname:8888/controller/action


    Walkthrough

    Ensure Fiddler can accept remote http requests on port 8888:

    Run Fiddler as administrator Go to Tools > Fiddler Options > Connections, and ensure that 'Allow remote computers to connect' is checked, and 'Fiddler listens on port' is set to 8888:

    Configure Fiddler to forward requests received on port 8888 to port 80

    • Close Fiddler
    • Start REGEDIT
    • Create a new DWORD named ReverseProxyForPort inside HKEY_CURRENT_USER\SOFTWARE\Microsoft\Fiddler2.
      • Now set the DWORD value to the local port you'd like to re-route inbound traffic to (generally port 80 for a standard HTTP server)
    • To do this, right-click the DWORD you created and select 'Modify'. Ensure 'Base' is set to 'Decimal' and enter '80' (or another port) as the 'Value data':

    Ensure that port 8888 is opened on the firewall

    • You must ensure that port 8888 is open to external requests (it won't be by default if your server is firewall-protected)

    That's it! Fiddler should now be set up as a reverse proxy, to intercept all requests from port 8888 (so that you can view them in Fiddler), and it will then forward them to your web server to actually be handled.

    Test a request

    • Restart Fiddler
    • To test that Fiddler is intercepting external requests, open a browser on the same machine where you've set up Fiddler as a reverse proxy. Navigate your browser to http://127.0.0.1:8888
    • This tests making a basic request to to port 8888
    • You should see the request intercepted by Fiddler
    • Now you can test a request from another machine, for example by making a request from a browser on another machine like this (where 'remoteHostname' is a hostname on the machine where you've set up Fiddler as a reverse proxy) :

    http://remoteHostname:8888/controller/action

    • Alternatively, you can compose a request by using another instance of Fiddler on a remote machine, using a URL similar to the one above. This will allow you to make either a GET or a POST request.

    IMPORTANT: Once you've finished viewing your request(s), go back to Tools > Fiddler Options > Connections and remove the 'Allow remote computers to connect' option, otherwise 3rd parties will be able to bounce traffic through your server

    0 讨论(0)
  • 2020-12-07 09:34

    Using Wireshark..

    I have not tried this: http://wiki.wireshark.org/CaptureSetup/Loopback

    If that works, you could then filter for http/http contains GET/http contains POST traffic.

    You might have to run two Wireshark instances, one capturing local, and one capturing remote. I'm not sure.

    0 讨论(0)
提交回复
热议问题