goproxy icon indicating copy to clipboard operation
goproxy copied to clipboard

proxy use python requests request https website can not working but http website working fine

Open ztitin opened this issue 2 years ago • 3 comments

I build a proxy server use proxy go, and write a client use python requests lib, but it's just working with http website, when i try to request https website reurn 407 code and the credential of proxy is correct.

Expected Behavior

python requests https website is same result like request http website

Current Behavior

python requests https website can not get result like request http website

Possible Solution

need you check

Steps to Reproduce

  1. write a client use python requests lib code as below
import requests

r = requests.get('https://headers.cf/api/headers',
                 proxies={'https': 'http://username:password@host:port'})
print(r.json())
  1. error log from proxy go as below
2021/11/20 08:25:50.856795 WARN new http request fail,ERR: basic auth fail
2021/11/20 08:25:50.856808 WARN connect to tcp parent  fail, ERR:basic auth fail from
  1. request http website is working fine
import requests

r = requests.get('http://headers.cf/api/headers',
                 proxies={'http': 'http://username:password@host:port'})
print(r.json())

Context (Environment)

  1. proxy version is : commercial_11.2
  2. full command is :
http
-t tcp
-p "0.0.0.0:8888"
--auth-url=
  1. system is : centos8

ztitin avatar Nov 20 '21 04:11 ztitin

pls using the latest requests library .

snail007 avatar Nov 20 '21 09:11 snail007

latest requests

Hi thanks for the reply i just using requests latest version 2.26.0 but still get same issue.

ztitin avatar Nov 20 '21 10:11 ztitin

@snail007 @ztitin 大佬好,请问这个问题有办法能解决吗,我也遇到了这个问题。详情如下

  • 我在拨号VPS上启动了代理服务,命令是 proxy http -t tcp -p :38080

  • 使用requests (requests==2.27.1) 发起http请求能成功,但是发起https请求始终报错

    • 请求代码
      proxies = {"http": "http://xxx.xx.xxx.x:38080", "https": "http://xxx.xx.xxx.x:38080"}
      response = requests.get('https://www.baidu.com', headers=headers, proxies=proxies, verify=False)
      
    • python端报错信息
      Traceback (most recent call last):
      requests.exceptions.SSLError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_UNEXPECTED_MESSAGE] sslv3 alert unexpected message (_ssl.c:1076)')))
      
    • 代理VPS服务端输出
      /01/19 15:26:44.881351 INFO CONNECT:www.baidu.com:443
      2022/01/19 15:26:44.881370 INFO use parent : false, www.baidu.com:443
      2022/01/19 15:26:44.881400 INFO ip xxx.xx.xxx.xxx rate, current: 1/s, max: 20/s
      2022/01/19 15:26:44.926393 INFO conn xxx.xx.xxx.xxx:63958 - xx.xxx.xxx.xx:443 connected [www.baidu.com:443]
      2022/01/19 15:26:44.980008 INFO conn xxx.xx.xxx.xxx:63958 - xx.xxx.xxx.xx:443 released [www.baidu.com:443]
      
  • 最后经过测试,使用curl发送https请求能成功

    curl -x  http://xxx.xx.xx.x:38080\
         'https://www.baidu.com' \
      -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' \
      --compressed
    

大佬你解决了吗,我遇到了相同的问题

fastjien avatar Jan 19 '22 14:01 fastjien