Skip to content

explicitly ipv6 address targeted requests leads to proxy error #1487

Open
@JJ-Author

Description

@JJ-Author

Describe the bug
ipv6 address targeted requests lead to http error 502 bad gateway due to "Name or service not known"

To Reproduce
Steps to reproduce the behavior:

  1. start proxy.py on a remote server having dual stack
startup details (note tried different host combinations)
    sys.argv += [
        '--ca-key-file', 'ca-key.pem',
        '--ca-cert-file', 'ca-cert.pem',
        '--ca-signing-key-file', 'ca-signing-key.pem',
    ]
    sys.argv += [
#        '--hostname', '0.0.0.0',
#        '--hostname', '::',
        '--hostname', '2a01:4f9:4b:479e::2',
        '--port', '8899',
        '--log-level', 'd',
        '--insecure-tls-interception',
#        '--basic-auth', 'user:pass',
#        '--plugins', __name__ + '.OntologyTimeMachinePlugin'
  1. try to use proxy on another device/client having dual stack curl -Ix http://[2a01:4f9:4b:479e::2]:8899 http://[2606:2800:21f:cb07:6820:80da:af6b:8b2c] (the upstream target is ipv6 of www.example.org)

Expected behavior
the request should be forwarded correctly to the upstream server and return the response (in the example 404 would be expected)

Version information

  • OS: Ubuntu 20.04 with dual stack (IPv4 and IPv6)
  • clients: chrome and curl
  • Device: Win11 client in another remote network also dual stack (IPv4 and IPv6)
  • proxy.py Version 2.4.8

Additional context

error log for request indicating that IPv6 address seems not identified correctly or is mistakenly sent for dns lookup

2024-10-05 14:36:08,255 - pid:2157929 [D] acceptor.accept:115 - Accepting new work#103                                                                                        
2024-10-05 14:36:08,257 - pid:2157929 [D] tcp_server.__init__:119 - Work#103 accepted from ::ffff:93.193.37.34:51246                                                          
2024-10-05 14:36:08,257 - pid:2157929 [D] tcp_server.initialize:131 - Handling connection ::ffff:93.193.37.34:51246                                                           
2024-10-05 14:36:08,258 - pid:2157929 [D] threadless._update_work_events:197 - fd#103 registered for mask#1 by work#103                                                       
2024-10-05 14:36:08,264 - pid:2157929 [D] handler.handle_readables:222 - Client is read ready, receiving...                                                                   
2024-10-05 14:36:08,264 - pid:2157929 [D] connection.recv:62 - received 181 bytes from client
2024-10-05 14:36:08,264 - pid:2157929 [D] server.connect_upstream:578 - Connecting to upstream [2606:2800:21f:cb07:6820:80da:af6b:8b2c]:80
2024-10-05 14:36:08,267 - pid:2157929 [W] server.connect_upstream:618 - Unable to connect with upstream [2606:2800:21f:cb07:6820:80da:af6b:8b2c]:80 due to [Errno -2] Name or 
service not known
2024-10-05 14:36:08,268 - pid:2157929 [W] handler.handle_data:184 - HttpProtocolException: ProxyConnectionFailed gaierror(-2, 'Name or service not known')
2024-10-05 14:36:08,268 - pid:2157929 [D] tcp_server.handle_readables:212 - Implementation signaled shutdown for client ::ffff:93.193.37.34:51246
2024-10-05 14:36:08,268 - pid:2157929 [D] tcp_server.handle_readables:218 - Client ::ffff:93.193.37.34:51246 has pending buffer, will be flushed before shutting down
2024-10-05 14:36:08,268 - pid:2157929 [D] threadless._update_work_events:166 - fd#103 modified for mask#2 by work#103
2024-10-05 14:36:08,268 - pid:2157929 [D] handler.handle_writables:193 - Client is write ready, flushing...
2024-10-05 14:36:08,268 - pid:2157929 [D] tcp_server.handle_writables:173 - Flushing buffer to client ::ffff:93.193.37.34:51246
2024-10-05 14:36:08,268 - pid:2157929 [D] connection.flush:101 - flushed 88 bytes to client
2024-10-05 14:36:08,268 - pid:2157929 [D] threadless._cleanup:311 - fd#103 unregistered by work#103
2024-10-05 14:36:08,269 - pid:2157929 [I] server.access_log:393 - ::ffff:93.193.37.34:51246 - HEAD [2606:2800:21f:cb07:6820:80da:af6b:8b2c]:80/ - None None - 0 bytes - 4.19ms
2024-10-05 14:36:08,269 - pid:2157929 [D] server.on_client_connection_close:384 - Closed server connection, has buffer False
2024-10-05 14:36:08,269 - pid:2157929 [D] handler.shutdown:89 - Closing client connection ::ffff:93.193.37.34:51246 has buffer False
2024-10-05 14:36:08,269 - pid:2157929 [D] handler.shutdown:99 - Client connection shutdown successful
2024-10-05 14:36:08,269 - pid:2157929 [D] handler.shutdown:113 - Client connection closed

different requests tried with curl

C:\Users\jf>curl -Ix http://[2a01:4f9:4b:479e::2]:8899 http://[2606:2800:21f:cb07:6820:80da:af6b:8b2c]
HTTP/1.1 502 Bad Gateway
Proxy-agent: proxy.py v2.4.8
Connection: close

C:\Users\jf>curl -Ix http://tools.dbpedia.org:8899 http://[2606:2800:21f:cb07:6820:80da:af6b:8b2c]
HTTP/1.1 502 Bad Gateway
Proxy-agent: proxy.py v2.4.8
Connection: close

## curl on remote server and also client
curl -I http://[2606:2800:21f:cb07:6820:80da:af6b:8b2c]
HTTP/1.1 404 Not Found
Content-Type: text/html
Date: Sat, 05 Oct 2024 12:29:12 GMT
Server: ECAcc (dcd/7D26)
Content-Length: 345

Metadata

Metadata

Assignees

Labels

BugBug report in proxy server

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions