-
-
Save haproxytechblog/3014386b2e7468c6b77dcc09c41c64e2 to your computer and use it in GitHub Desktop.
Announcing HAProxy Data Plane API 2.7
This file contains hidden or 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:password \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "name": "mirror", | |
| "command": "spoa-mirror --runtime 0 --mirror-url http://test.local", | |
| "user": "myusername", | |
| "group": "mygroupname", | |
| "start-on-reload": "enabled" | |
| }' \ | |
| "http://127.0.0.1:5555/v2/services/haproxy/configuration/programs?version=1" |
This file contains hidden or 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
| program mirror | |
| command spoa-mirror --runtime 0 --mirror-url http://test.local | |
| user myusername | |
| group mygroupname | |
| option start-on-reload |
This file contains hidden or 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:password \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "name": "php_fpm", | |
| "docroot": "/var/www/myapp", | |
| "index": "index.php", | |
| "path-info": "^(/.+\\.php)(/.*)?$", | |
| "log-stderr": [ | |
| { | |
| "global": true | |
| } | |
| ] | |
| }' \ | |
| "http://127.0.0.1:5555/v2/services/haproxy/configuration/fcgi_apps?version=2" |
This file contains hidden or 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
| fcgi-app php_fpm | |
| docroot /var/www/myapp | |
| index index.php | |
| path-info ^(/.+\.php)(/.*)?$ | |
| log-stderr global |
This file contains hidden or 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:password \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "name": "mymailers", | |
| "timeout": 20000 | |
| }' \ | |
| "http://127.0.0.1:5555/v2/services/haproxy/configuration/mailers_sections?version=4" |
This file contains hidden or 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:password \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "name": "smtp1", | |
| "address": "192.168.0.1", | |
| "port": 587 | |
| }' \ | |
| "http://127.0.0.1:5555/v2/services/haproxy/configuration/mailer_entries?version=5" |
This file contains hidden or 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
| mailers mymailers | |
| timeout mail 20000 |
This file contains hidden or 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:password \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "name": "website-1", | |
| "error_files": [ | |
| { | |
| "code": 400, | |
| "name": "/etc/haproxy/errorfiles/site1/400.http" | |
| }, | |
| { | |
| "code": 404, | |
| "name": "/etc/haproxy/errorfiles/site1/404.http" | |
| } | |
| ] | |
| }' \ | |
| "http://127.0.0.1:5555/v2/services/haproxy/configuration/http_errors_sections?version=3" |
This file contains hidden or 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
| http-errors website-1 | |
| errorfile 400 /etc/haproxy/errorfiles/site1/400.http | |
| errorfile 404 /etc/haproxy/errorfiles/site1/404.http | |
| mailer smtp1 192.168.0.1:587 |
This file contains hidden or 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:password \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "index": 0, | |
| "status": 503, | |
| "errorfiles": "website-1" | |
| }' \ | |
| "http://127.0.0.1:5555/v2/services/haproxy/configuration/http_error_rules?parent_type=backend&parent_name=test&version=6" |
This file contains hidden or 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
| http-error status 503 errorfiles website-1 |
This file contains hidden or 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 http | |
| mode http | |
| timeout connect 10000 | |
| timeout client 30000 | |
| timeout server 30000 | |
| defaults tcp | |
| mode tcp | |
| frontend fe_1 from http | |
| bind 0.0.0.0:80 | |
| frontend fe_2 from tcp | |
| bind 0.0.0.0:3000 | |
| timeout connect 20000 |
This file contains hidden or 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 | |
| mode http | |
| timeout connect 10000 | |
| timeout client 30000 | |
| timeout server 30000 | |
| frontend fe_1 | |
| bind 0.0.0.0:80 | |
| defaults | |
| mode tcp | |
| frontend fe_2 | |
| bind 0.0.0.0:3000 | |
| timeout connect 20000 |
This file contains hidden or 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 unnamed_defaults_1 | |
| mode http | |
| timeout connect 10000 | |
| timeout client 30000 | |
| timeout server 30000 | |
| defaults unnamed_defaults_2 | |
| mode tcp | |
| frontend fe_1 from unnamed_defaults_1 | |
| bind 0.0.0.0:80 | |
| frontend fe_2 from unnamed_defaults_2 | |
| bind 0.0.0.0:3000 | |
| timeout connect 20000 |
This file contains hidden or 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
| haproxy: | |
| config_file: "/etc/haproxy/haproxy.cfg" | |
| haproxy_bin: "haproxy" | |
| reload: | |
| reload_cmd: "systemctl reload haproxy" | |
| restart_cmd: "systemctl restart haproxy" | |
| status_cmd: "systemctl status haproxy" |
This file contains hidden or 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
| reload_cmd: "sudo -n systemctl reload haproxy.service" | |
| restart_cmd: "sudo -n systemctl restart haproxy.service" | |
| status_cmd: "systemctl --quiet is-active haproxy.service" |
This file contains hidden or 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
| reload_cmd: "s6-svc -2 /etc/service.d/haproxy" | |
| restart_cmd: "s6-svc -r /etc/service.d/haproxy" | |
| status_cmd: "s6-svstat -u /etc/service.d/haproxy" |
This file contains hidden or 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
| haproxy: | |
| config_file: "/etc/haproxy/haproxy.cfg" | |
| haproxy_bin: "haproxy" | |
| reload: | |
| reload_strategy: "systemd" | |
| service_name: "haproxy-2.4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment