简体   繁体   English

将Fiddler作为HTTP到HTTPS反向代理运行

[英]Running Fiddler as HTTP to HTTPS reverse proxy

I have a service running on my machine. 我的机器上正在运行服务。 This service is published on HTTPS and starting it on HTTP seems a bit complicated. 此服务在HTTPS上发布,并且在HTTP上启动它似乎有点复杂。 A certain remote machine perform calls to my machine on HTTP (and this is not under my control). 某个远程计算机通过HTTP执行对我的计算机的调用(这不受我的控制)。 I want to perform some non-performance-critical tests with my service, and it looks like the simplest way is to use somewhat like HTTP to HTTPS reverse proxy. 我想对我的服务执行一些对性能没有要求的测试,看起来最简单的方法是使用类似HTTP到HTTPS的反向代理。 Fiddler works great with HTTP to HTTP and HTTPS to HTTPS scenarios, but I'm not able to make it work for my case. Fiddler在HTTP到HTTP和HTTPS到HTTPS场景中都可以很好地工作,但是我无法使其适用于我的情况。 Thus what I need: 因此,我需要:

+----------------+          +--------------------------------+
| Remote machine | -------> | My machine                     |
|                |  HTTP    | Fiddler    -------> My machine |
|                |          |            HTTPS    service    |
+----------------+          +--------------------------------+

Can I achieve this using Fiddler? 我可以使用Fiddler来实现吗?

Sure, Fiddler can convert inbound requests from HTTP to HTTPS. 当然,Fiddler可以将入站请求从HTTP转换为HTTPS。

The simplest way would be to add something inside OnBeforeRequest like: 最简单的方法是在OnBeforeRequest中添加一些内容,例如:

if (oSession.HostnameIs("myhost") && 
    (oSession.oRequest.pipeClient.LocalPort == 80)) 
{
  oSession.fullUrl = "https://" + oSession.url;
}

This presumes, of course, that Fiddler was configured to run on port 80, the default port for HTTP. 当然,这假定Fiddler配置为在端口80(HTTP的默认端口)上运行。 You can run it on whatever port you like (eg if port 80 were already in use) but you'd need to change the port in the URL that the client requests, and if you could do that, you'd probably be able to change the client to use a HTTPS URL to begin with. 您可以在所需的任何端口上运行它(例如,如果端口80已经被使用),但是您需要更改客户端请求的URL中的端口,如果可以的话,您可能可以更改客户端以使用HTTPS URL开头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM