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

feature request: support socks proxy #91

Closed
ex-nerd opened this issue Dec 2, 2021 · 8 comments
Closed

feature request: support socks proxy #91

ex-nerd opened this issue Dec 2, 2021 · 8 comments

Comments

@ex-nerd
Copy link

ex-nerd commented Dec 2, 2021

I use a socks proxy (via ssh) to communicate with servers inside of a VPC. It would be nice if this could be specified either directly in the .http file config, or via examples for how to set this up with an inline script.

@AnWeber
Copy link
Owner

AnWeber commented Dec 2, 2021

You could solve this using socks-proxy-agent (see sindresorhus/got#7 (comment)). Can you test the following if it works for you.

  • npm install socks-proxy-agent (and npm initbeforehand if no package.json exists)
  • Add this script to your http file
{{@request

const SocksProxyAgent = require('socks-proxy-agent');
const tunnel = new SocksProxyAgent({
	host: 'br41.nordvpn.com',
	userId: '[email protected]',
	password: 'abcdef12345124'
});
request.agent = tunnel;

}}

It is important to set http.proxy='' and http.proxySupport=off in vscode. Using httpyac cli it is not needed. VSCode is really tricky to use with proxy support.

If this works, I can consider adding this to httpyac. I can't really test it unfortunately.

@AnWeber
Copy link
Owner

AnWeber commented Dec 19, 2021

Since I don't run a SockJS proxy I can't test it unfortunately. If there is still a need for the feature, please just reopen the issue.

@AnWeber AnWeber closed this as completed Dec 19, 2021
@ex-nerd
Copy link
Author

ex-nerd commented Dec 19, 2021

I still haven't had time to give this a try. I got as far as pasting the code into my test script and then distracted. I think I need to figure out where the node is that httpyac runs, since I don't have a "system" node to work with.

No need for any special proxy software, though. you can just open one via ssh with ssh -D 1080 user@host and then set your proxy to localhost:1080.

@AnWeber AnWeber reopened this Dec 19, 2021
@AnWeber
Copy link
Owner

AnWeber commented Dec 19, 2021

Thanks for the info. Will try the ssh approach:-)

AnWeber pushed a commit to AnWeber/httpyac that referenced this issue Dec 29, 2021
@AnWeber
Copy link
Owner

AnWeber commented Dec 29, 2021

I have now tried the integration of the socks proxy. I also tested it using an SSH server, but if my test setup was correct, I am not 100% sure. Could you please test it once after release and give feedback? Thanks.

# @proxy socks://127.0.0.1:1080

GET https://httpbin.org/json HTTP/1.1

You can test the change with v4.9.0.

@ex-nerd
Copy link
Author

ex-nerd commented Jan 21, 2022

Sorry for such a long delay in replying.. I tested your code above in 4.9.1 with and without that # and the query runs successfully no matter what value I put in for the proxy. I would expect some sort of timeout if the proxy port/URL I give doesn't exist (or is malformed if I use something like # @proxy socks://127.0.0.1:abcd)

I also tested it with servers I know require a proxy, and the requests time out, which suggests the proxy isn't activating.

@AnWeber
Copy link
Owner

AnWeber commented Jan 21, 2022

Phew, then I need help. I tested it with the Kubernetes Api, which is only accessible via Jumphost. I have performed the following steps:

  1. open SSH Proxy
ssh -D 1111 [email protected]
  1. created http request
# @proxy socks://127.0.0.1:1111
# @noRejectUnauthorized
GET https://10.1.26.1:6443/openapi/v2

In the browser, the URL is not reachable. Without # @proxy socks://127.0.0.1:1111 the URL is not reachable. With # @proxy socks://127.0.0.1:1111 it is reachable.
Did I miss something?

@AnWeber
Copy link
Owner

AnWeber commented Jan 30, 2022

Please add a more detailed description of how I can recreate the problem. I will close the ticket until then, because I currently do not know how to follow up the problem. thanks.

@AnWeber AnWeber closed this as completed Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants