Closed
Description
Hello,
I'm currently a minor roadblock whilst using the fasthttp package.
I have done research into proxy support, however, I have only found one outstanding solution as of yet
This would be using the HostClient and setting the address (as shown in the code example below):
client = &fasthttp.HostClient{ Addr: "localhost:24000", }
However, when I attempt to make outgoing HTTPS requests, they do not work. Instead a non-HTTP request is sent/made. There appears to be no support for http.Transport either to set the proxy through this instance.
Is there any other way to set a proxy and make outgoing HTTPS (GET/POST/etc) requests using FastHTTP?
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
kirillDanshin commentedon Aug 15, 2018
hi @frxncisjoseph, welcome to the family :)
We can prepare an example for full-featured reverse proxy. I did one a couple of months ago for myself but it may take a while 'cause I need to prepare the sources for example purposes :)
frxncisjoseph commentedon Aug 15, 2018
Hi @kirillDanshin, thank you for the greetings! I would absolutely love that a lot as I'm in the need of guidance, haha. I'd love to be able to make outgoing HTTPs requests under a proxy through
.Get
or other means.erikdubbelboer commentedon Sep 1, 2018
@frxncisjoseph how would you implement this if you did have something like
net.Transport
? I see https://godoc.org/golang.org/x/net/proxy doesn't support HTTP proxies. For thenet/http
package it seems buildin.I guess something like this might work? I don't have any HTTP proxy so I can't test it at the moment.
Which you can then use with:
frxncisjoseph commentedon Sep 6, 2018
@erikdubbelboer That didn't work, sadly. :(
erikdubbelboer commentedon Sep 7, 2018
@frxncisjoseph I have modified my comment to a version that does work for me with https://tinyproxy.github.io/. Does it work for you now?
frxncisjoseph commentedon Oct 4, 2018
Excellent work, bravo!
tsenart commentedon Mar 26, 2020
@erikdubbelboer: As part of my effort to integrate this library with Vegeta, I found that the Client is missing any built-in support for proxying HTTP(S) requests. For the time being, I'll make it so vegeta uses the standard library client if users specify proxy options, but it'd be great to have this natively supported in fasthttp.
erikdubbelboer commentedon Mar 27, 2020
@tsenart the
FasthttpHTTPDialer
function I commented above doesn't work for you? If it does I guess we could add it to https://godoc.org/github.com/valyala/fasthttp/fasthttpproxy so everyone can use it more easy.tsenart commentedon Mar 27, 2020
@erikdubbelboer: I haven't tried it. I'm wondering if it's spec compliant? Does it support HTTPS proxying? Would like to see some tests in place for that code, rather than having it be somewhat fringe utility package.
erikdubbelboer commentedon Mar 30, 2020
To be honest I have no idea if it's spec compliant. As I said above I tested the code with https://tinyproxy.github.io/ and it worked. That's all I did. I'm afraid I currently don't have time to test this more and read the spec. You have tried using the code for your use case?
Fenny commentedon Apr 14, 2020
@erikdubbelboer, I tested your example with multiple http/https proxies from multiple providers. All worked fine without errors 👍
It might be good to add an optional user:pass parser if exist in addr
user:pass@proxy:port
erikdubbelboer commentedon Apr 21, 2020
I have added the code to this repo. See: 54df169 Thanks!
SaishNaik commentedon Jul 18, 2020
@erikdubbelboer , #290 (comment) .
Following your suggestion here,
I used this to connect to proxy URL
My proxy is of the following form :
http://username-country-us:password@72.229.28.185:4055
Now when I use
FasthttpHTTPDialer
, It tries to connect with72.229.28.185:4055
as proxy , not the whole proxy url I mentioned above.If I edit
FasthttpHTTPDialer
to use the exact proxy, get this error again"error: too many colons in address"
.Note: this same proxy url works well with standard http client :
any suggestions?
erikdubbelboer commentedon Jul 18, 2020
That's not how authentication works for HTTP proxies. The username and password get turned into a
Proxy-Authorization
header that gets send with theCONNECT
request. See:fasthttp/fasthttpproxy/http.go
Lines 34 to 36 in 34a61fe
What you are trying to do doesn't make any sense.
karthik-uj commentedon Oct 17, 2024
We can pass a CA certificate (if available for the proxy server) like so:
You can also turn off SSL certificate verification using the
InsecureSkipVerify
option if a CA certificate is not available. Do not use that on production.