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

关于代理 #1

Open
swimmingchar opened this issue Mar 9, 2022 · 2 comments
Open

关于代理 #1

swimmingchar opened this issue Mar 9, 2022 · 2 comments

Comments

@swimmingchar
Copy link

您好,如果我要部署在一台内网服务器上,然后是通过squid代理出去的,我怎么加HTTP_PROXY?我不想加全局变量的方式添加啊

@trazfr
Copy link
Owner

trazfr commented Aug 1, 2022

Hello,

I don't speak Chinese, so I'm not sure I will correctly answer the question.
I have understood that you would like to connect through an HTTP Proxy like squid or other.

But I don't see the problem. Just using the environment variables http_proxy and https_proxy seems to work.
Like any Go program using the net/http lib, it does support those environment variables.

As an example I will do like this.
Beware: this is only for illustration purpose. Directly connecting in plain HTTP over the Internet is insecure.

 tcp over ws client      proxy server                         tcp over ws server               tcp over ws server
+------------------+    +-------------------------------+    +---------------------------+    +--------+
| netcat           | -> | http://proxy.example.com:8899 | -> | ws://tow.example.com:8080 | -> | netcat |
+------------------+    +-------------------------------+    +---------------------------+    +--------+
  • On the tcp over ws server. Start a dummy TCP server:

    echo 'hello from remote' | nc -l -p 5678
  • On the tcp over ws server. The server DNS is tow.example.com:

    ./tcp-over-websocket server -listen_ws 0.0.0.0:8080 -connect_tcp 127.0.0.1:5678
  • On the proxy server (I don't have any Squid, but I use proxy.py for this example). The server DNS is proxy.example.com in this example:

    python -m venv ./venv
    ./venv/bin/pip install proxy.py
    ./venv/bin/proxy --hostname 0.0.0.0 --port 8899
  • On tcp over ws client:

    # for ws://
    export http_proxy=http://proxy.example.com:8899
    # for wss://
    export https_proxy=http://proxy.example.com:8899
    ./tcp-over-websocket client -listen_tcp 127.0.0.1:1234 -connect_ws ws://tow.example.com:8080
  • On tcp over ws client:

    echo 'hello from local' | nc 127.0.0.1:1234
    # we print in the console:
    # - "hello from remote" on the tcp over ws client
    # - "hello from local" on the tcp over ws server

It worked like this.

Could you please describe with more details your issue in English?

@swimmingchar
Copy link
Author

Thank you very much for your detailed instructions.
I originally planned to change the data transfer between zabbix_proxy and zabbix_server from TCP to HTTP.
At present, the program has been written through the introduction of the TCP communication method on the Zabbix official website.
I'm very sorry, I just saw your description now, I will set up an environment to verify it.
Thanks again very much.

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