- Reverse proxy supporting multiple services and domains
- Basic rate limiting with Redis
- Basic caching with Redis
- Hot reloading of endpoints and services
- Log publishing to Loki
services:
proxy:
image: d4rckh/voltgate:latestports:
- "80:80"# proxy port
- "9999:9999"# management portvolumes:
- ./voltgate.yaml:/app/config.yamlservices:
- name: service_nameurl: http://localhost:9090endpoints:
- host: domain.comservice: service_nameUsing the grafana.json file you can import the dashboard below in your instance!
management:
address: ":9999"# Default: ":9999"proxy:
address: ":80"# Default: ":80"config:
reload_interval: 10# Reloads monitoring, services, and endpoints every 10 seconds# Default: do not reloadstorage:
redis:
address: localhost:6379password: my-passwordusername: my-username# Configure Redis for use in rate limitingrate_limit:
storage: redis# Use Redis for rate limiting# Default: memory (Not recommended for production!)cache:
storage: redis# Use Redis for caching# Default: memory (Not recommended for production!)monitoring:
loki: http://localhost:3100/loki/api/v1/push# Publishes logs to Loki# Default: do not publishprometheus: true# Exposes /metrics on the management address# Default: falseservices:
- name: service_nameurl: http://localhost:9090endpoints:
- host: domain.comservice: service_namecache:
rules:
- path: "^/myendpoint"ttl: 10# secondsparams: ["param1", "params2"] # Optional array of params to construct the cache key, by default it will use all params# Optional caching rules, will cache all GET requests that match the regex path, make sure to configure Redis for production rate_limit:
rules:
- path: "^/api/some_action"# regexmethod: POST # must be definedwindow: 10# secondsrequests: 2# Optional rate limiting rules, make sure to configure Redis for productionVoltgate Proxy collects and exposes metrics to Prometheus for monitoring.
Counts the total number of HTTP requests received.
- Type: Counter
- Labels:
method: HTTP method (e.g., GET, POST)host: Original requested hosttarget_service_name: Proxied service namepath: Request pathstatus: HTTP response status code
rate(http_requests_total{method="GET", status="200"}[5m])
(Displays the rate of successful GET requests over 5 minutes.)
Counts the total number of blocked HTTP requests.
- Type: Counter
- Labels:
method: HTTP method (e.g., GET, POST)host: Original requested hosttarget_service_name: Proxied service namepath: Request path
rate(http_blocked_requests_total[5m])
(Displays the rate of successful blocked requests over 5 minutes.)
Measures the duration of HTTP requests in seconds.
- Type: Histogram
- Buckets: Default Prometheus latency buckets (
0.005s,0.01s,0.025s, ...) - Labels:
method: HTTP methodhost: Requested hosttarget_service_name: Proxied service namepath: Request path
histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))
(Displays the 95th percentile of request durations over the last 5 minutes.)
Tracks the size of HTTP responses in bytes.
- Type: Histogram
- Buckets: Exponential buckets (starting at 100 bytes, scaling by a factor of 2, up to 10 steps)
- Labels:
method: HTTP methodhost: Requested hosttarget_service_name: Proxied service namepath: Request path
histogram_quantile(0.5, rate(http_response_size_bytes_bucket[5m]))
(Displays the median response size over the last 5 minutes.)
Prometheus metrics are available via an HTTP endpoint. Ensure the monitoring service is running and query the endpoint:
GET /metrics
Add the following to prometheus.yml to enable scraping of the proxy service:
scrape_configs:
- job_name: "voltgate_proxy"static_configs:
- targets: ["localhost:9999"] # Management address set in the configuration