diff --git a/README.md b/README.md index 1c4f7fc..c0663e5 100644 --- a/README.md +++ b/README.md @@ -26,18 +26,6 @@ Easy Proxy supports the following features: - [x] HTTP - [ ] HTTPS -## Use from source -```bash -# Clone the repository -git clone https://github.com/AssetsArt/easy-proxy.git -# Change the working directory -cd easy-proxy -# Build the application -cargo build --release -# Run the application // EASY_PROXY_CONF is the environment variable to set the configuration file path -EASY_PROXY_CONF=.config/easy_proxy.yaml ./target/release/runtime -``` - ## Example configuration ### Global Configuration @@ -102,4 +90,54 @@ routes: path: /svc/v1 service: name: backend_service +``` + +## Use from docker-compose + +```yaml +# docker-compose.yml +version: '3.8' +services: + easy-proxy: + image: ghcr.io/assetsart/easy-proxy:latest + ports: + - 8088:8088 + volumes: + - ./examples:/app/examples + networks: + - gateway + http-echo-1: + image: hashicorp/http-echo:latest + command: ["-text", "Hello, World 3002"] + ports: + - "3002:5678" + networks: + - gateway + http-echo-2: + image: hashicorp/http-echo:latest + command: ["-text", "Hello, World 3003"] + ports: + - "3003:5678" + networks: + - gateway +networks: + gateway: {} +``` +```bash +$ docker-compose up +``` +```bash +$ curl -H "Host: mydomain.com" http://localhost:8088/api/v1 +``` + +## Use from source +```bash +# Clone the repository +$ git clone https://github.com/AssetsArt/easy-proxy.git +# Change the working directory +$ cd easy-proxy +# Build the application +$ cargo build --release +# Run the application // EASY_PROXY_CONF is the environment variable to set the configuration file path +$ EASY_PROXY_CONF=.config/easy_proxy.yaml ./target/release/runtime ``` \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..78d5309 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,28 @@ +version: '3.8' +services: + easy-proxy: + image: ghcr.io/assetsart/easy-proxy:latest + ports: + - 8088:8088 + volumes: + - ./examples:/app/examples + networks: + - gateway + http-echo-1: + image: hashicorp/http-echo:latest + command: ["-text", "Hello, World 3002"] + ports: + - "3002:5678" + networks: + - gateway + http-echo-2: + image: hashicorp/http-echo:latest + command: ["-text", "Hello, World 3003"] + ports: + - "3003:5678" + networks: + - gateway + + +networks: + gateway: {} diff --git a/examples/proxy.yaml b/examples/proxy.yaml index 5559fa6..271a4ed 100644 --- a/examples/proxy.yaml +++ b/examples/proxy.yaml @@ -7,10 +7,13 @@ services: - name: backend_service algorithm: round_robin # round_robin, random, consistent, weighted endpoints: - - ip: 127.0.0.1 + - ip: 172.20.0.1 port: 3002 weight: 1 # Optional - + - ip: 172.20.0.1 + port: 3003 + weight: 1 # Optional + # A list of routes to be proxied routes: - host: mydomain.com @@ -21,18 +24,17 @@ routes: value: "123" # olny string paths: - pathType: Exact # Exact, Prefix - path: /api/v1 + path: / service: - rewrite: /old_service/v1 # Optional name: backend_service - pathType: Prefix # Exact, Prefix path: /api/v1 service: rewrite: /service/v1 # Optional name: backend_service - - header: svc.service1 # from header key "x-easy-proxy-svc" - paths: - - pathType: Prefix # Exact, Prefix - path: /svc/v1 - service: - name: backend_service \ No newline at end of file + # - header: svc.service1 # from header key "x-easy-proxy-svc" + # paths: + # - pathType: Prefix # Exact, Prefix + # path: /svc/v1 + # service: + # name: backend_service \ No newline at end of file diff --git a/proxy/src/lib.rs b/proxy/src/lib.rs index 848d568..6d4a120 100644 --- a/proxy/src/lib.rs +++ b/proxy/src/lib.rs @@ -110,14 +110,14 @@ impl ProxyHttp for Proxy { let services = match services::find(session) { Some(val) => val, None => { - tracing::error!("[request_filter] Service not found"); + // tracing::error!("[request_filter] Service not found"); return response::service_unavailable(session).await; } }; let backend = match backend::selected(services.backend) { Some(val) => val, None => { - tracing::error!("[request_filter] Backend not found"); + // tracing::error!("[request_filter] Backend not found"); return response::service_unavailable(session).await; } };