mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-20 05:49:09 +00:00
docker support
This commit is contained in:
parent
05cb35fabb
commit
c0c7fda891
3 changed files with 81 additions and 0 deletions
28
Dockerfile
Normal file
28
Dockerfile
Normal file
|
@ -0,0 +1,28 @@
|
|||
####################################################################################################
|
||||
## Builder
|
||||
####################################################################################################
|
||||
FROM rust:latest AS builder
|
||||
|
||||
WORKDIR /worker
|
||||
COPY ./ .
|
||||
RUN cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
|
||||
####################################################################################################
|
||||
## Final image
|
||||
####################################################################################################
|
||||
FROM ubuntu:latest
|
||||
WORKDIR /app
|
||||
|
||||
ENV TUN=tun0
|
||||
ENV PROXY=
|
||||
ENV DNS=virtual
|
||||
ENV MODE=auto
|
||||
ENV BYPASS_IP=
|
||||
|
||||
RUN apt update && apt install -y iproute2 curl && apt clean all
|
||||
|
||||
COPY --from=builder /worker/target/x86_64-unknown-linux-gnu/release/tun2proxy /usr/bin/tun2proxy
|
||||
COPY --from=builder /worker/docker/entrypoint.sh /app
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
24
README.md
24
README.md
|
@ -108,6 +108,30 @@ Currently, tun2proxy supports HTTP, SOCKS4/SOCKS4a and SOCKS5. A proxy is suppli
|
|||
URL format. For example, an HTTP proxy at `1.2.3.4:3128` with a username of `john.doe` and a password of `secret` is
|
||||
supplied as `--proxy http://john.doe:secret@1.2.3.4:3128`. This works analogously to curl's `--proxy` argument.
|
||||
|
||||
## Docker Support
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
-e PROXY=PROXY_TYPE://PROXY_IP:PROXY_PORT \
|
||||
-v /dev/net/tun:/dev/net/tun \
|
||||
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
|
||||
--sysctl net.ipv6.conf.default.disable_ipv6=0 \
|
||||
--cap-add NET_ADMIN \
|
||||
--name tun2proxy \
|
||||
image:tags
|
||||
```
|
||||
|
||||
Provide a network to another worker container. (share netns).
|
||||
|
||||
```bash
|
||||
docker run -it \
|
||||
-d \
|
||||
--network "container:tun2proxy" \
|
||||
worker-example:tags
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Configuration Tips
|
||||
### DNS
|
||||
When DNS resolution is performed by a service on your machine or through a server in your local network, DNS resolution
|
||||
|
|
29
docker/entrypoint.sh
Normal file
29
docker/entrypoint.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
run() {
|
||||
if [ -n "$BYPASS_IP" ]; then
|
||||
BYPASS_IP="--bypass-ip $BYPASS_IP"
|
||||
fi
|
||||
|
||||
if [ -n "$DNS" ]; then
|
||||
DNS="--dns $DNS"
|
||||
fi
|
||||
|
||||
if [ -n "$MODE" ]; then
|
||||
MODE="--setup $MODE"
|
||||
fi
|
||||
|
||||
if [ -n "$PROXY" ]; then
|
||||
PROXY="--proxy $PROXY"
|
||||
fi
|
||||
|
||||
if [ -n "$TUN" ]; then
|
||||
TUN="--tun $TUN"
|
||||
fi
|
||||
|
||||
exec tun2proxy $TUN $PROXY $DNS $MODE $BYPASS_IP
|
||||
}
|
||||
|
||||
|
||||
run || echo "Runing ERROR!!"
|
Loading…
Add table
Reference in a new issue