-
Notifications
You must be signed in to change notification settings - Fork 209
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
Why would this be a bad request? #774
Comments
@pnip I will try if I can answer your question as I don't use telnet much. Hoverfly is an HTTP proxy, in order to use it to simulate or capture your telnet traffic, you need to set up telnet to use localhost:8500 as a proxy where hoverfly listens on. |
@tommysitu telnet is just to simulate a connection (incidently nc could be use instead) to hoverfly, once the connection is established (just like what a 1.1 browser does, I believe) be that a normal http connection or https connection with HTTP "CONNECT" handled by hoverfly + SSL negotiation is done, a 1.1 session is established, and supposedly one can request url without any specifying host nor port nor scheme in any subsequent request url. But I think each request still need a "Host: foo.bar" header (presumable for checking for 400 bad request) I should explain further I find that if I do the following it works as expected: C02V81EGHTDD-lm:trafficserver pnip$ nc localhost 8500 HTTP/1.1 200 OK |
@pnip I'm very interested in your use case. Are you trying to setup HTTP tunnel via hoverfly proxy to use telnet? What's your end goal in doing this, to capture and simulate the telnet session? It may not work as you have pointed out as it hasn't been tested for telnet before. Maybe you have tried this out already, but if you haven't, have a look at proxychains, it should let you configure a proxy for telnet. |
@tommysitu nah this is not for capture/simulate telnet session but for creating an repeatable integration testing framework for our server/client stacks. |
From what I see @pnip you started telnet on the same port that is used by the http proxy. Telnet will use TCP/IP or similar, not http, so a http proxy will barf. If so it's a problem that has nothing to do with Hoverfly. |
I'm persuaded this is a bug caused by the relative path not being processed correctly. |
Revisited this issue again, and GoProxy is not working properly with telnet requests. It should be able to get the destination from the Host header for HTTP 1.1 request. |
I am seeing similar issues, trying to use Hoverfly as a MITM (man-in-the-middle) proxy between an Envoy (reverse) proxy and our application server. The use case is for recording a bunch of requests down to Requests like this work fine:
If I retry this with relative URL, I get the same error:
The problem is not in itself related to The problem is more specifically this code in the upstream goproxy lib; as @tommysitu suggested, it doesn't handle non-absolute URLs. In this case, "absolute" is presumed to mean a full URL with This issue on the goproxy side indicates that this by design because goproxy is a forward proxy and not a reverse proxy. OTOH, I get the feeling from reading this example in the goproxy repo that it could actually be made to work; it's at least possible to use goproxy as a transparent (forward) proxy by overriding the |
@perlun, that's exactly what the problem is. Getting the host from the Host header should fix it. Hoverfly already has a reverse proxy mode, check here https://github.com/SpectoLabs/hoverfly/blob/master/core/proxy.go#L109 You can do Feel free to submit a PR if you'd like to contribute. |
Thanks for the reply @tommysitu. 👍 Good to hear more about the reverse proxying mode. However, in our case, the capturing is the critical part, so we ended up opting for another solution for now (for reference, the Envoy tap filter described here: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/tap_filter#config-http-filters-tap). Since we already use Envoy, taking that into use was easy for our particular use case. It would however be nice to be able to to use Hoverfly in this mode, so I will support someone trying to fix it. 🙂 However, will not spend time on it myself. |
-bash-4.1$ export PATH=$PATH:~
-bash-4.1$ hoverctl status
+------------+----------+
| Hoverfly | running |
| Admin port | 8888 |
| Proxy port | 8500 |
| Proxy type | forward |
| Mode | capture |
| Middleware | disabled |
+------------+----------+
-bash-4.1$ telnet localhost 8500
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
Host: thecure.com
User-Agent: Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp) .default/1538949339-2
Accept: /
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Sun, 07 Oct 2018 23:33:21 GMT
Content-Length: 64
This is a proxy server. Does not respond to non-proxy requests.
^]
telnet> quit
Connection closed.
-bash-4.1$
https://github.com/SpectoLabs/goproxy/blob/master/proxy.go#L108-L110
Why does the url has to be absolute? If a Host header is provided
The text was updated successfully, but these errors were encountered: