使用docker搭建socks5代理

本文详细描述了如何使用Dante在RuntimeFabric中设置无用户密码验证的SOCKS5代理,以满足AnypointMonitoring的需求。涉及docker-compose配置和防火墙设置,适用于非标准MuleSoft产品技术援助。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我参考MuleSoft Help Center成功搭建了socks5代理服务器

文字内容如下(怕以后访问不了)

How to set up a testing SOCKS5 proxy (dante) for Anypoint monitoring in RTF (Runtime Fabric)

A demonstration to set up a SockS5 proxy with Dante and set up the proxy in RTF. This KB involves none standard MuleSoft offering product. Technical assistance for such products is limited to this article. Please use at your own risk.

Jul 23, 2019•Knowledge

Content

GOAL

Usually, RTF is running in a secured environment with proxies for communications between the Anypoint control plane. Most of the communications are HTTP/HTTPS and require an HTTP/HTTPS proxy. However, Anypoint Monitoring uses SOCKS5 proxies for sending metrics and logs out to the control plane. 

This KB demonstrates how to set up a Dante SOCKS5 server for Anypoint Monitoring in RTF. Please note Dante is not part of the MuleSoft product set. Technical assistance for such products is limited to this article. 

PROCEDURE

Set up a Dante proxy

We recommend using a docker-compose file to set up the Dante server, which is suggested here at https://hub.docker.com/r/vimagick/dante

Create a folder and change the working directory to the folder. create docker-compose.yml 

dante:
  image: vimagick/dante
  ports:
    - "1080:1080"
  volumes:
    - ./sockd.conf:/etc/sockd.conf
  restart: always

Create sockd.conf. Update 172.19.0.0/16 to the CIDR of RTF cluster

debug: 0
logoutput: stderr
internal: 0.0.0.0 port = 1080
external: eth0
socksmethod: username none
clientmethod: none
user.privileged: root
user.unprivileged: nobody

client pass {
    from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
    log: error
}

socks pass {
    from: 172.19.0.0/16 to: 0.0.0.0/0
    socksmethod: username
    log: error
}

Bring up the Dante server and set the credentials. Replace "user1" and "password" with your own username and password. 

$ docker-compose up -d
$ docker exec -it dante_dante_1 bash
>>> useradd user1
>>> echo user1:password | chpasswd
>>> exit

Set up a firewall rule to allow traffic from the RTF nodes to port 1080 on the proxy firewall

Test the proxy on your RTF cluster. Replace the 172.19.0.23 with the IP of the proxy server. "client certificate not found" shows no client certificate is sent but it means the connectivity via the proxy is good. 

curl -kx socks5h://user1:password@172.19.0.23:1080 https://dias-ingestor-nginx.prod.cloudhub.io:5044
curl: (52) NSS: client certificate not found (nickname not specified)

Update monitoring proxy on RTF 

Follow the instructions here to set up the proxy on RTF. 

> rtfctl apply monitoring-proxy "socks5://user1:password@172.19.0.23:1080"

Restart applications to pick up the proxy. In the anypoint-monitoring container log, it should show the connection established. 

2019-07-22T03:55:56.037Z	INFO	transport/proxy.go:70	
proxy host: '172.19.0.23:1080'
...
2019-07-22T03:56:17.241Z	INFO	pipeline/output.go:95	
Connecting to backoff(async(tcp://dias-ingestor-nginx.prod.cloudhub.io:5044))
2019-07-22T03:56:18.344Z	INFO	pipeline/output.go:105	
Connection to backoff(async(tcp://dias-ingestor-nginx.prod.cloudhub.io:5044)) established
...

 

Disclaimer: This article involves products and technologies which do not form part of the MuleSoft product set. Technical assistance for such products is limited to this article.

Attachments

而我不想有用户密码验证和ip地址限制,所以修改配置如下:

debug: 0
logoutput: stderr
internal: 0.0.0.0 port = 1080
external: eth0
socksmethod: username none
clientmethod: none
user.privileged: root
user.unprivileged: nobody

client pass {
    from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
    log: error
}

socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    socksmethod: username none
    log: error
}

祝你好运,畅游网络

### 一键部署支持多个IP地址的SOCKS5代理服务器 为了满足需求,可以编写一个自动化脚本来完成此过程。该脚本不仅会安装并配置 SOCKS5 代理服务,还会设置必要的防火墙规则以允许通过指定 IP 地址访问代理服务。 #### 准备工作 确保目标机器已安装 Docker 和基础开发环境工具包。对于基于 Debian 或 Ubuntu 的 Linux 发行版来说,可以通过以下命令来准备: ```bash sudo apt-get update && sudo apt-get install -y docker.io curl git build-essential ``` #### 自动化脚本内容 下面是一个简化的一键部署脚本示例,它将拉取 `nps` 镜像,并对其进行基本配置以便于作为 SOCKS5 代理运行[^3]。 ```bash #!/bin/bash # 设置变量 NPS_IMAGE="ffdfgdfg/nps" CONF_DIR="./conf" # 创建配置文件夹 mkdir -p $CONF_DIR # 下载默认配置文件到本地 curl -o "$CONF_DIR/nps.conf" https://raw.githubusercontent.com/ehang-io/nps/master/conf/nps.conf.example # 修改配置文件中的必要参数, 如web管理界面用户名密码等. sed -i 's/^web_username = .*/web_username = admin/' "$CONF_DIR/nps.conf" sed -i 's/^web_password = .*/web_password = complexPassword123!@#/g' "$CONF_DIR/nps.conf" # 添加多IP支持部分 echo " bridge { name = \"socks\" type = \"tcp\" port = 1080 }" >>"$CONF_DIR/nps.conf" # 启动容器 docker pull $NPS_IMAGE docker run -d \ --name=nps \ --restart=always \ --net=host \ -v ${CONF_DIR}:/conf \ $NPS_IMAGE # 输出提示信息 echo "SOCKS5 proxy server has been deployed successfully." echo "You can now connect to the SOCKS5 service on this machine using any of its available IPs and port 1080." ``` 请注意,在实际环境中应当更加注意安全性措施,比如使用更复杂且随机生成的密码代替硬编码形式,并考虑如何安全地存储这些敏感数据[^1]。 上述脚本实现了自动化的 SOCKS5 代理服务器部署流程,包括但不限于获取镜像、创建所需目录结构以及调整初始配置等方面的工作。此外,还特别加入了针对多 IP 支持的功能模块,使得最终构建出来的代理实例能够响应来自不同网络接口上的请求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值