Last active
January 15, 2024 14:50
-
-
Save haproxytechblog/019d085c73dc1c6c7fba592f38dc30c9 to your computer and use it in GitHub Desktop.
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 --get --user admin:mypassword \ | |
http://localhost:5555/v2/services/haproxy/configuration/backends |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
http://localhost:5555/v2/services/haproxy/transactions?version=1 |
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":5,"id":"9663c384-5052-4776-a968-abcef032aeef","status":"in_progress"} |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"name": "test_backend", "mode":"http", "balance": {"algorithm":"roundrobin"}, "httpchk": {"method": "HEAD", "uri": "/", "version": "HTTP/1.1"}}' \ | |
http://localhost:5555/v2/services/haproxy/configuration/backends?transaction_id=9663c384-5052-4776-a968-abcef032aeef |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"name": "server1", "address": "127.0.0.1", "port": 8080, "check": "enabled", "maxconn": 30, "weight": 100}' \ | |
"http://localhost:5555/v2/services/haproxy/configuration/servers?backend=test_backend&transaction_id=9663c384-5052-4776-a968-abcef032aeef" |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"name": "test_frontend", "mode": "http", "default_backend": "test_backend", "maxconn": 2000}' \ | |
http://localhost:5555/v2/services/haproxy/configuration/frontends?transaction_id=9663c384-5052-4776-a968-abcef032aeef |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"name": "http", "address": "*", "port": 80}' \ | |
"http://localhost:5555/v2/services/haproxy/configuration/binds?frontend=test_frontend&transaction_id=9663c384-5052-4776-a968-abcef032aeef" |
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 -X PUT --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
http://localhost:5555/v2/services/haproxy/transactions/9663c384-5052-4776-a968-abcef032aeef |
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 test_frontend | |
mode http | |
maxconn 2000 | |
bind *:80 name http | |
default_backend test_backend | |
backend test_backend | |
mode http | |
balance roundrobin | |
option httpchk HEAD / HTTP/1.1 | |
server server1 127.0.0.1:8080 check maxconn 30 weight 100 |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
http://localhost:5555/v2/services/haproxy/transactions?version=2 | |
{"_version":2,"id":"7d0d6737-655e-4489-92eb-6d29cdd69827","status":"in_progress"} |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"name": "example_servers", "mode":"http", "balance": {"algorithm":"roundrobin"}}' \ | |
http://localhost:5555/v2/services/haproxy/configuration/backends?transaction_id=7d0d6737-655e-4489-92eb-6d29cdd69827 |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"name": "server1", "address": "127.0.0.1", "port": 8081, "check": "enabled", "maxconn": 30, "weight": 100}' \ | |
"http://localhost:5555/v2/services/haproxy/configuration/servers?backend=example_servers&transaction_id=7d0d6737-655e-4489-92eb-6d29cdd69827" |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"index": 0, "acl_name": "is_example", "criterion": "req.hdr(Host)", "value": "example.com"}' \ | |
"http://localhost:5555/v2/services/haproxy/configuration/acls?parent_type=frontend&parent_name=test_frontend&transaction_id=7d0d6737-655e-4489-92eb-6d29cdd69827" |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"index": 0, "cond": "if", "cond_test": "is_example", "name": "example_servers"}' \ | |
"http://localhost:5555/v2/services/haproxy/configuration/backend_switching_rules?frontend=test_frontend&transaction_id=7d0d6737-655e-4489-92eb-6d29cdd69827" |
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 -X POST --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
-d '{"index": 0, "cond": "if", "cond_test": "{ path /admin.php } !{ src 192.168.50.20/24 }", "type": "deny"}' \ | |
"http://localhost:5555/v2/services/haproxy/configuration/http_request_rules?parent_type=frontend&parent_name=test_frontend&transaction_id=7d0d6737-655e-4489-92eb-6d29cdd69827" |
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 -X PUT --user admin:mypassword \ | |
-H "Content-Type: application/json" \ | |
http://localhost:5555/v2/services/haproxy/transactions/7d0d6737-655e-4489-92eb-6d29cdd69827 |
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 test_frontend | |
mode http | |
maxconn 2000 | |
bind *:80 name http | |
acl is_example req.hdr(Host) example.com | |
http-request deny deny_status 0 if { path /admin.php } !{ src 192.168.50.20/24 } | |
use_backend example_servers if is_example | |
default_backend test_backend | |
backend example_servers | |
mode http | |
balance roundrobin | |
server server1 127.0.0.1:8081 check maxconn 30 weight 100 | |
backend test_backend | |
mode http | |
balance roundrobin | |
option httpchk HEAD / HTTP/1.1 | |
server server1 127.0.0.1:8080 check maxconn 30 weight 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment