VProxy is a zero-dependency TCP Loadbalancer based on Java NIO. The project only requires Java 11 to run.
Clone it, compile it, then everything is ready for running.
- TCP Loadbalancer with TLS termination
- HTTP/1.x and HTTP/2 Loadbalancer with
Host
header consideration - Other tcp based protocol loadbalancer, such as grpc, dubbo
- Socks5 server
- DNS server and customizable A|AAAA records
- Kubernetes integration
- Many other standalone extended apps, such as
WebSocksProxyAgent
andWebSocksProxyServer
use pre-built releases
See the release page.
Use the latest vproxy-linux
binary file in release page.
Or
Use the jlink built runtime here.
Use the latest vproxy-macos
binary file in release page.
Java runtime can be found here.
Use the jlink built runtime here.
NOTE: the runtime is in beta state.
pack
./gradlew clean jar
java -jar build/libs/vproxy.jar -Deploy=HelloWorld
jlink
make jlink
./build/image/bin/vproxy -Deploy=HelloWorld
docker
docker build --no-cache -t vproxy:latest https://raw.githubusercontent.com/wkgcass/vproxy/master/docker/Dockerfile
docker run --rm vproxy -Deploy=HelloWorld
graal native-image
./gradlew clean jar
native-image -jar build/libs/vproxy.jar --enable-all-security-services --no-fallback --no-server vproxy
./vproxy -Deploy=HelloWorld
use native fds impl
Only macos(bsd)/linux supported. And you might need to set the JAVA_HOME
env variable before compiling.
make vfdposix
java -Dvfd=posix -Djava.library.path=./base/src/main/c -jar build/libs/vproxy.jar -Deploy=HelloWorld
For info about F-Stack
, check the doc fstack-how-to.md.
And there's a special version for windows to support Tap devices: -Dvfd=windows
, however the normal fds and event loop are stll based on jdk selector channel.
make vfdwindows
java -Dvfd=posix -Djava.library.path=./base/src/main/c -jar build/libs/vproxy.jar -Deploy=HelloWorld
test
Run test cases:
./gradlew runTest
Test vswitch, docker network plugin, vpctl, k8s controller:
# requires virtualbox installed
cd ./misc/auto-setup/
./auto-setup.sh
./auto-verify.sh
- Zero dependency: no dependency other than java standard library, and no jni extensions.
- Simple: keep code simple and clear.
- Modifiable when running: no need to reload for configuration update.
- Fast: performance is one of our main priorities.
- TCP Loadbalancer: we now support TCP and TCP based protocols, also allow your own protocols.
- Kubernetes: integrate vproxy resources into k8s.
use vproxy with kubernetes
Add crd, launch vproxy and controller
kubectl apply -f https://github.com/vproxy-tools/vpctl/blob/master/misc/crd.yaml
kubectl apply -f https://github.com/vproxy-tools/vpctl/blob/master/misc/k8s-vproxy.yaml
Launch the example app
kubectl apply -f https://github.com/vproxy-tools/vpctl/blob/master/misc/cr-example.yaml
Detailed info can be found here.
vpctl
A command line client application is provided to manipulate the vproxy instance. You may see more info in vpctl repo.
This tool is fully tested and simple to use. Some examples are provided in the tool repo for reference.
Simple mode
You can start a simple loadbalancer in one command:
java -Deploy=Simple -jar vproxy.jar \
bind {port} \
backend {host1:port1,host2:port2} \
[ssl {path of cert1,cert2} {path of key} \]
[protocol {...} \]
Use help
to view the parameters.
Standard mode
Use help
to view the launching parameters.
When launching the vproxy instance, a http-controller
on port 18776 and a resp-controller
on port 16309 will be started. Then you can operate the vproxy instance using curl
or redis-cli
. You may also operate the vproxy instance directly using standard input (stdin).
See command.md and api doc for more info.
Questions about implementation detail are also welcome (in issues).
- how-to-use.md: How to use config file and controllers.
- api.yaml: api doc for http-controller in swagger format.
- command.md: Detailed command document.
- lb-example.md: An example about running a loadbalancer.
- docker-example.md: An example about building and running vproxy in docker.
- architecture.md: Something about the architecture.
- extended-app.md: The usage of extended applications.
- websocks.md: The WebSocks Protocol.
- vproxy-kcp-tunnel.md: The KCP Tunnel Protocol.
- using-application-layer-protocols.md: About how to use (customized) application layer protocols.
- fstack-how-to.md: How to run vproxy upon
F-Stack
. Chinese version only for now. - vpws-direct-relay.md: How to use
direct-relay
invpws-agent
.
Currently only I
myself is working on this project. I would be very happy if you want to join :)
Thanks to Jetbrains for their great IDEs and the free open source license.