-
-
Save haproxytechblog/50cea2b61041b748b80a2f92fd90c37d to your computer and use it in GitHub Desktop.
AWS EC2 Service Discovery with HAProxy
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
$ ssh -i ~/MyKeyPair.pem ubuntu@<public_ip_of_instance> |
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
$ sudo nano /etc/hapee-2.2/hapee-lb.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
userlist hapee-dataplaneapi | |
user admin insecure-password adminpwd |
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
$ sudo apt install -y whois | |
$ mkpasswd -m sha-256 mypassword | |
# encrypted password: | |
# $5$sj7aJ5nSSX1693nT$IVBQYoexyD2qaTeMOTym6evFqHRN9289gIw9UyAHKp5 |
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
userlist hapee-dataplaneapi | |
user admin password $5$sj7aJ5nSSX1693nT$IVBQYoexyD2qaTeMOTym6evFqHRN9289gIw9UyAHKp5 |
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
$ sudo systemctl restart hapee-2.2-lb |
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
$ curl -H 'Content-Type: application/json' -u admin:adminpwd -d '{ | |
"access_key_id":"AKIAXXXXXXXXXXXXXXXX", | |
"secret_access_key":"ZGSNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", | |
"description":"AWS EC2 Production Environment", | |
"enabled":true, | |
"ipv4_address":"private", | |
"name":"www", | |
"region":"us-east-1", | |
"retry_timeout":10}' http://127.0.0.1:5555/v2/service_discovery/aws |
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
{ | |
"access_key_id": "AKIAXXXXXXXXXXXXXXXX", | |
"allowlist": null, | |
"denylist": null, | |
"description": "AWS EC2 Production Environment", | |
"enabled": true, | |
"id": "ffdf439e-a947-4401-a0db-6f7cb3ac3c40", | |
"ipv4_address": "private", | |
"name": "www", | |
"region": "us-east-1", | |
"retry_timeout": 10, | |
"secret_access_key": "ZGSNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", | |
"server_slots_base": 10, | |
"server_slots_growth_type": "exponential" | |
} |
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
backend aws-us-east-1-www-API-80 | |
server SRV_4vhrR 172.31.0.70:80 check weight 128 | |
server SRV_jOEoa 127.0.0.1:80 disabled weight 128 | |
server SRV_tce8j 127.0.0.1:80 disabled weight 128 | |
server SRV_njnGf 127.0.0.1:80 disabled weight 128 | |
server SRV_R0V1R 127.0.0.1:80 disabled weight 128 | |
server SRV_Bc83k 127.0.0.1:80 disabled weight 128 | |
server SRV_mnkyy 127.0.0.1:80 disabled weight 128 | |
server SRV_zMQ6S 127.0.0.1:80 disabled weight 128 | |
server SRV_MowJa 127.0.0.1:80 disabled weight 128 | |
server SRV_4oEP4 127.0.0.1:80 disabled weight 128 |
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
frontend public_web_servers | |
mode http | |
log global | |
timeout client | |
bind *:80 | |
default_backend aws-us-east-1-www-API-80 |
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
$ sudo systemctl reload hapee-2.2-lb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment