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
Virtual Hosts Plugin #729
Comments
I think
Let me know how it goes. |
So, to modify |
|
No you don't need to clone the source code.
|
Yep feel free to modify it per your needs. |
Ok, in the example, it has |
This fails: |
Not sure what's in there. Below is a working example I just tried on local machine:
╰─ ls -1 /tmp/plug ─╯
__pycache__
my_plugin.py
╰─ cat /tmp/plug/my_plugin.py ─╯
from proxy.http.proxy import HttpProxyBasePlugin
class MyPlugin(HttpProxyBasePlugin):
pass
╰─ PYTHONPATH=/tmp/plug python -m proxy --plugin my_plugin.MyPlugin ─╯
2021-11-17 18:45:59,656 - pid:26374 [I] plugins.load:82 - Loaded plugin proxy.http.proxy.HttpProxyPlugin
2021-11-17 18:45:59,657 - pid:26374 [I] plugins.load:82 - Loaded plugin my_plugin.MyPlugin
2021-11-17 18:45:59,657 - pid:26374 [I] listener.setup:84 - Listening on ::1:8899
2021-11-17 18:45:59,715 - pid:26374 [I] executors.setup:158 - Started 16 threadless workers
2021-11-17 18:45:59,830 - pid:26374 [I] pool.setup:91 - Started 16 acceptors |
You can use both |
Can you expand? Remove |
In the example plugin, you skip the plugin if it has the https header. So, if I implement TLS interception, can I remove that. Also, got it to work, but there's an error: |
:) Yes you need to implement the plugin abstract methods. I just gave you an example on how to load a plugin. Also looks like you are using stable release from |
Did you try |
Oh, that's perfect. Ok, going to give this another go. |
Yeah, so if I try to run it with the git version, it just hangs. I'm guessing the methods are still required, they just won't give an error? |
I won't recommend using
So nothing should break or hang. Locally I am able to run it just fine. Made an I am on ╰─ PYTHONPATH=/tmp/plug python -m proxy --plugins my_plugin.MyPlugin ─╯
2021-11-17 19:05:42,695 - pid:28677 [I] plugins.load:82 - Loaded plugin proxy.http.proxy.HttpProxyPlugin
2021-11-17 19:05:42,696 - pid:28677 [I] plugins.load:82 - Loaded plugin my_plugin.MyPlugin
2021-11-17 19:05:42,696 - pid:28677 [I] listener.setup:84 - Listening on ::1:8899
2021-11-17 19:05:42,751 - pid:28677 [I] executors.setup:158 - Started 16 threadless workers
2021-11-17 19:05:42,881 - pid:28677 [I] pool.setup:91 - Started 16 acceptors
2021-11-17 19:05:55,212 - pid:28705 [I] server.access_log:430 - ::1:49195 - GET httpbin.org:80/get - 200 OK - 484 bytes - 645.35ms
2021-11-17 19:06:04,957 - pid:28699 [I] server.access_log:430 - ::1:49205 - CONNECT httpbin.org:443 - 5900 bytes - 1151.83ms |
Hmmm, even the empty one isn't working. |
Does proxy work fine for you without any external plugin? |
Oh, forgot to enable |
It loads, but not to the address (the redirect to custom server plugin). |
Your address might be unreachable. Always verify using curl first, whether your upstream actually works. But overall looks like you have got what we were after. Feel free to leave more comments for discussion, but I think good to close this for now. |
Ok, it works with curl, but not in a browser. |
Aka |
Yes, because browsers are not dumb like curl, that's why :D. I am pretty sure, google has HSTS enabled which will prohibit browsers from even making an http request to google. Anyways, does it go to |
Also note that default response from in-built web server is $ proxy --plugin proxy.plugin.RedirectToCustomServerPlugin --enable-web-server ╰─ curl -v -x localhost:8899 http://httpbin.org/get ─╯
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8899 (#0)
> GET http://httpbin.org/get HTTP/1.1
> Host: httpbin.org
> User-Agent: curl/7.64.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 404 NOT FOUND
< Server: proxy.py vv2.3.2-dev147.g35b643c.d20211114
< Content-Length: 0
< Connection: close
<
* Closing connection 0 |
Hmmm, seems like more work is needed to figure this out. Thank you though. |
No worries, lemme know, feel free to open another ticket for |
Is your feature request related to a problem? Please describe.
I want to run a bunch of local services on different ports, and have a proxy that can connect to each of them
Describe the solution you'd like
For example, the proxy is on port 80, and I have my personal DNS that resolves
*.test
to127.0.0.1
. When I go toexample.test
, the proxy will then go to127.0.0.1:5000
for example.The text was updated successfully, but these errors were encountered: