Skip to content

Commit

Permalink
Merge pull request #44 from AssetsArt/main
Browse files Browse the repository at this point in the history
release
  • Loading branch information
Aitthi authored Mar 7, 2024
2 parents 6ea1b34 + 23c13da commit 93bd071
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 24 deletions.
62 changes: 50 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
```
28 changes: 28 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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: {}
22 changes: 12 additions & 10 deletions examples/proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
# - header: svc.service1 # from header key "x-easy-proxy-svc"
# paths:
# - pathType: Prefix # Exact, Prefix
# path: /svc/v1
# service:
# name: backend_service
4 changes: 2 additions & 2 deletions proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down

0 comments on commit 93bd071

Please sign in to comment.