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

"Empty" GET-Request ("GET / HTTP1.1") causes exception #228

Open
JoeyVinc opened this issue Oct 20, 2024 · 3 comments
Open

"Empty" GET-Request ("GET / HTTP1.1") causes exception #228

JoeyVinc opened this issue Oct 20, 2024 · 3 comments
Labels

Comments

@JoeyVinc
Copy link

JoeyVinc commented Oct 20, 2024

When PX gets an GET-header which is not set (or "/") although the HOST header is set, PX throws an exception.
Expected behavior: if an HOST header is set accept it as target address.

Example:

curl -v \
   -H "Host:example.com" \
   -H "Forwarded:for=192.168.178.23;proto=http;host=example.com" \
   -H "X-Real-IP:192.168.178.23" \
   -H "X-Forwarded-For:192.168.178.23" \
   -H "X-Forwarded-Proto:http" \
   http://192.168.178.23:3128

PX runs on local machine (192....:3128); requested host is example.com

Log:

* Trying 192.168.178.23:3128...
* Connected to 192.168.178.23 (192.168.178.23) port 3128 (#0)
> GET / HTTP/1.1
> Host:example.com
> User-Agent: curl/7.81.0
> Accept: */*
> Forwarded:for=192.168.178.23;proto=http;host=example.com
> X-Real-IP:192.168.178.23
> X-Forwarded-For:192.168.178.23
> X-Forwarded-Proto:http
>
* Empty reply from server
* Closing connection 0
curl: (52) Empty reply from server

Debug-Log of PX:

Process-1: MainThread: 1729448331: /_handle_request_noblock/verify_request/dprint: Client address: 192.168.178.23
Process-1: MainThread: 1729448331: /_handle_request_noblock/verify_request/dprint: Host-only IP allowed
Process-1: Thread_0: 1729448331: /do_curl/do_client_auth/dprint: No client authentication required
Process-1: Thread_0: 1729448331: /do_curl/__init__/dprint: e36a4173bf6dfec31f2fabd0fb81a953e968a627: New curl instance
Process-1: Thread_0: 1729448331: /__init__/_setup/dprint: e36a4173bf6dfec31f2fabd0fb81a953e968a627: GET / using HTTP/1.1
Process-1: Thread_0: 1729448331: /do_GET/do_curl/dprint: e36a4173bf6dfec31f2fabd0fb81a953e968a627: Path = /
----------------------------------------
Exception occurred during processing of request from ('192.168.178.23', 3414)
[...]    netloc = (spl[0], int(spl[1]))
                      ^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '///'
@JoeyVinc JoeyVinc changed the title "Empty" GET-Request ("GET / HTTP1.1") caused exception "Empty" GET-Request ("GET / HTTP1.1") causes exception Oct 20, 2024
@genotrance
Copy link
Owner

Px is a proxy so it expects curl --proxy http://192.168.178.23:3128 style of usage. The Host header is for virtual hosting, not forwarding. Can you please explain why you expect this to work?

@JoeyVinc
Copy link
Author

JoeyVinc commented Nov 3, 2024

I used CURL just to make the issue visible.
In fact I use nginx as a proxy/router in my docker configuration. At the moment I use the stream-support of nginx to route proxy requests to another local running "px" instance (which does re-route the request to another company proxy).

client --> nginx --> px --> company proxy

Due to the fact, that the stream func of nginx cannot "manipulate" HTTP requests (e.g. add header data or route a URL-X to a URL-B) the idea is, to use instead of a stream a normal HTTP request (with Proxy-headers).

An there we are: HTTP GET requests in NGINX always begins with a "\" --> nginx itself try to send this request to the local PX instance. Therefore we get an empty (or only a backslash) GET request. This is what I replayed with CURL.

@genotrance genotrance removed the waiting label Nov 8, 2024
@genotrance
Copy link
Owner

I won't claim to really understand the setup above. Is this something that is supported by HTTP or by proxies in general? Any documentation to that order will help proceed on a generic way to solve this.

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

No branches or pull requests

2 participants