Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProxyHandler处理https失败 #476

Open
pantaopt opened this issue Jan 30, 2023 · 6 comments
Open

ProxyHandler处理https失败 #476

pantaopt opened this issue Jan 30, 2023 · 6 comments

Comments

@pantaopt
Copy link

pantaopt commented Jan 30, 2023

使用反向代理,譬如将
https://www.baidu.com 转发到 http://192.168.1.1 上,
发现https的url,ProxyHandler中处理出来的outResponse均是400、301、302。

@yanzhenjie
Copy link
Owner

贴下代码、

@pantaopt
Copy link
Author

就是README中的示例代码。
我的场景是VPN+自定义域名,DNS因为服务器那边不愿意做公网转发,Android VpnService的DNS配置支持配置备用DNS,但是存在抢在主DNS前面解析的问题。因此我这边使用AndServer。

因为本机80端口无法使用,我指定了特定端口,比如8666,VpnService有个setHttpProxy的Api,使用VPN给整个手机设置http代理。测试发现:全都会走到ProxyHandler中进行处理,http的url显示正常,https的URL被重定向无法显示,比如百度、京东等知名网站。

@pantaopt
Copy link
Author

@yanzhenjie
顺便问一个问题:proxyServer的使用,想实现 http://1.demo.com/ 转发到 http://192.168.1.1/ 上,
AndServer.proxyServer().port(xxx).build()
这里的端口port必须是默认的80吗?

@pantaopt
Copy link
Author

image

运行demo工程,在浏览器访问 http://1.demo.com 报错不会跳转到百度

@yanzhenjie
Copy link
Owner

yanzhenjie commented Apr 15, 2024

抱歉回复太迟了,还是留一些信息吧:1.demo.com可能内网没有解析,所以可以先用ip代理试试。假设:

AndServer.proxyServer()
    .addProxy("192.168.1.11", "https://www.baidu.com")
    .port(8111)
    .build()
    .startup();

那么访问地址应该是:http://192.168.1.11:8111,你的代码中应该是http://1.demo.com:8111

@yanzhenjie
Copy link
Owner

访问https网站返回301、302等重定向状态码,我怀疑是AndServer内部没有处理重定向,我需要看源码确认一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants