docker-compose build --no-cache haproxy && docker-compose up -d
$ curl 0.0.0.0:8080/echob/metrics
hello from service b
$ curl 0.0.0.0:8080/echoa/metrics
hello from service a
Created
May 4, 2020 22:34
-
-
Save juanpabloaj/d840f3835652115f833a9a550bc798e5 to your computer and use it in GitHub Desktop.
haproxy strip path prefix
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.3" | |
services: | |
service-a: | |
image: hashicorp/http-echo | |
command: -text="hello from service a" | |
service-b: | |
image: hashicorp/http-echo | |
command: -text="hello from service b" | |
haproxy: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
ports: | |
- "8080:8080" | |
depends_on: | |
- service-a | |
- service-b |
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
FROM haproxy:1.7 | |
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg |
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
defaults | |
log global | |
retries 3 | |
maxconn 2000 | |
timeout connect 5s | |
timeout client 50s | |
timeout server 50s | |
frontend services-echo | |
mode http | |
bind :8080 | |
acl echoa_path path_beg /echoa | |
acl echob_path path_beg /echob | |
use_backend echoa if echoa_path | |
use_backend echob if echob_path | |
backend echoa | |
mode http | |
reqrep ^([^\ ]*\ /)echoa[/]?(.*) \1\2 | |
server service-a service-a:5678 | |
backend echob | |
mode http | |
reqrep ^([^\ ]*\ /)echob[/]?(.*) \1\2 | |
server service-b service-b:5678 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment