cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
20.28k stars 1.1k forks source link

Cannot connect to a http peer #180

Closed Bluemangoo closed 3 months ago

Bluemangoo commented 3 months ago

I want to proxy a http upstream, and it reported Upstream ConnectedTimedout.

More intuitive:

image image

vicanso commented 3 months ago

It may be the port 25000 can not access from internet, you can try:

telnet 8.xxx 443
telnet 8.xxx 25000
Bluemangoo commented 3 months ago

Thanks, for your reply🤗. However, it can be access, and I can access it in the browser.

IMG_20240404_081515.jpg

vicanso commented 3 months ago

Do you mind if I use your service for testing?

Bluemangoo commented 3 months ago

that's ok. but i cannot get log on port 25000, only nginx log on port 443.

vicanso commented 3 months ago

I found the problem, set Host: xxx:25000 resolve this problem. Your service may detect the request host.

Bluemangoo commented 3 months ago

I wrote these code, and i set it to xxx:25000, and i still failed.

image

vicanso commented 3 months ago

The host value should be IP:25000, I guess gittea only accepts the request with header Host: IP:25000.

vicanso commented 3 months ago
image image
Bluemangoo commented 3 months ago

image

hmmm..

Bluemangoo commented 3 months ago

Can you paste your code please?

vicanso commented 3 months ago

https://github.com/vicanso/pingap/blob/main/src/proxy/server.rs#L384 https://github.com/vicanso/pingap/blob/main/src/proxy/location.rs#L143

The function adds proxy to upstream.

vicanso commented 3 months ago

Connection reset by peer if you set host like this:

curl -H "Host: 127.0.0.1:6018" 'http://xxx:25000/' -v

> GET / HTTP/1.1
> Host: 127.0.0.1:6018
> User-Agent: curl/8.4.0
> Accept: */*
>
* Recv failure: Connection reset by peer
* Closing connection
curl: (56) Recv failure: Connection reset by peer
Bluemangoo commented 3 months ago

Fixed. Thanks.