我编写了一个运行在localhost:8000
上的小型代理服务器,它应该替换特定urls上的一些内容,同时保留其他urls的原样。
它目前所做的是将Example Domain
替换为example.com
页面上的Hello World!
。为了构建这个包,我使用了proxy-tamper
包。
代码看起来如下(保存在proxy-server.js
中):
"use strict";
const proxy = require('proxy-tamper').start({port: 8000});
// block share-term.me
proxy.tamper(/share-term.me\/$/, 'This content is blocked!');
// Replace the content on example.com
proxy.tamper(/example.com\/$/, request => {
delete request.headers['accept-encoding'];
request.onResponse(response => {
response.body = response.body.replace(/Example Domain/g, 'Hello World!');
response.headers['server'] = 'proxy-tamper 1337';
response.headers['content-length'] = response.body.length;
response.complete();
});
});
然后,要启动我使用的代理服务器:
node proxy-server.js
最后,通过设置google-chrome-stable
选项启动--proxy-server
:
google-chrome-stable --proxy-server='http=http://localhost:8000;https=http://localhost:8000' http://domain.com
这对于http://example.com
很好,但是对于https://example.com
却失败了。实际上,它不支持https
。
当我打开http://example.com
时,我会看到替换的内容:
但是当我打开https://example.com
(或任何https
url)时,它会失败,以ERR_EMPTY_RESPONSE
结尾。
如何为代理服务器添加https
支持,或至少使Chrome绕过https
urls到http
我试着使用--ignore-certificate-errors
和--allow-insecure-content
运行Chrome进程,但它们没有帮助。
我对拥有强大的https相关安全性并不感兴趣,但我希望通过我的服务器代理这些https请求,并在客户机上发送响应。
发布于 2016-10-13 03:11:03
看起来,代理篡改程序对https请求没有任何功能。它只支持http (编写这篇文章和查看文档)。
您可以使用包节点-http-代理代替。有一个关于支持https 这里的很好的部分。
编辑是否可以验证您是否真的可以更改https响应体服务器端?这些信息技术上不会被加密吗?服务器上的解密是否技术上违反了协议而不被允许?
https://stackoverflow.com/questions/40011633
复制相似问题