[GH-ISSUE #458] proxy use python requests request https website can not working but http website working fine #365

Open
opened 2026-02-27 23:16:39 +03:00 by kerem · 3 comments
Owner

Originally created by @ztitin on GitHub (Nov 20, 2021).
Original GitHub issue: https://github.com/snail007/goproxy/issues/458

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
Originally created by @ztitin on GitHub (Nov 20, 2021). Original GitHub issue: https://github.com/snail007/goproxy/issues/458 <!--- Provide a general summary of the issue in the Title above --> 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 <!--- Tell us what should happen --> python requests https website is same result like request http website ## Current Behavior <!--- Tell us what happens instead of the expected behavior --> python requests https website can not get result like request http website ## Possible Solution <!--- Not obligatory, but suggest a fix/reason for the bug, --> need you check ## Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug. Include code to reproduce, if relevant --> 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()) ``` 2. 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 ``` 3. 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) <!--- How has this issue affected you? What are you trying to accomplish? --> <!--- Providing context helps us come up with a solution that is most useful in the real world --> 1. proxy version is : commercial_11.2 2. full command is : ``` http -t tcp -p "0.0.0.0:8888" --auth-url= ``` 3. system is : centos8
Author
Owner

@snail007 commented on GitHub (Nov 20, 2021):

pls using the latest requests library .

<!-- gh-comment-id:974624233 --> @snail007 commented on GitHub (Nov 20, 2021): pls using the latest requests library .
Author
Owner

@ztitin commented on GitHub (Nov 20, 2021):

latest requests

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

<!-- gh-comment-id:974626743 --> @ztitin commented on GitHub (Nov 20, 2021): > latest requests Hi thanks for the reply i just using requests latest version 2.26.0 but still get same issue.
Author
Owner

@fastjien commented on GitHub (Jan 19, 2022):

@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
    

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

<!-- gh-comment-id:1016540478 --> @fastjien commented on GitHub (Jan 19, 2022): > @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 > ``` 大佬你解决了吗,我遇到了相同的问题
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/goproxy#365
No description provided.