Last active
April 16, 2024 12:45
-
-
Save testillano/3f7ff732850f42a6e7ee625aa182e617 to your computer and use it in GitHub Desktop.
http2 load balancer using docker-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
h2a: | |
image: ghcr.io/testillano/h2agent_http1:4.2.5 | |
hostname: h2a | |
#expose: | |
# - "8001" | |
ports: | |
# Ephemeral (use 'docker-compose ps' to see them) | |
- "8001" | |
- "8074" | |
volumes: | |
- ./matching.json:/conf/matching.json | |
- ./provision.json:/conf/provision.json | |
#command: ["-l", "Debug", "--verbose"] | |
command: ["--traffic-server-matching", "/conf/matching.json", "--traffic-server-provision", "/conf/provision.json"] | |
nginx: | |
image: nginx:latest | |
volumes: | |
- ./nginx.conf:/etc/nginx/nginx.conf:ro | |
depends_on: | |
- h2a | |
ports: | |
- "8006:8006" | |
networks: | |
default: | |
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"algorithm": "FullMatching" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 100; | |
events { | |
worker_connections 2048; | |
} | |
http { | |
upstream backend { | |
server h2a:8001; | |
} | |
access_log off; | |
server { | |
listen 8006; | |
http2 on; | |
location / { | |
#proxy_pass http://h2a:8001; | |
proxy_pass http://backend; | |
proxy_http_version 1.1; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_buffering off; | |
proxy_read_timeout 300s; | |
proxy_connect_timeout 120s; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"requestMethod": "GET", | |
"responseCode": 200, | |
"responseDelayMs": 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes: NGINX is not capable to act as http2 client towards backend, so this must be HTTP/1.1. So, we need to use h2agent_http1 image instead of h2agent, because we need HTTP1 support for this server.