marathon-lb icon indicating copy to clipboard operation
marathon-lb copied to clipboard

Add an option to extend an apps frontend and backend definition

Open Laures opened this issue 9 years ago • 3 comments

currently the only way to add settings to an apps frontend or backend definition is to overwrite an existing template by copy/pasting its current content and add whatever option is required.

this results in an overly complex marathon config and is not very save, as templates might change in the future.

as an option there could be a template (for example: HAPROXY_{0}_BACKEND_ADDITION) that is empty by default and is added to the backend definition of the app.

Laures avatar May 04 '16 13:05 Laures

Excuse me please! I have the problem. example: Default template for HAPROXY_HTTP_BACKEND_REDIR:

acl is_root path -i / acl is_domain hdr(host) -i {hostname} redirect code 301 location {redirpath} if is_domain is_root

then I want to modify like this

acl is_my_root path -i {my_path} acl is_my_domain hdr(host) -i {my_hostname} redirect code 301 location {redirpath} if is_my_domain is_my_root

how ?
if couldn't maybe I will modify source code.but i am not good at python. @brndnmtthws

Da-Hong avatar Mar 10 '17 03:03 Da-Hong

I can't help you with that. Good luck!

brndnmtthws avatar Mar 10 '17 03:03 brndnmtthws

I have found the way to solve my problem.

Use HAPROXY_0_BACKEND_HTTP_OPTIONS to override, like this:

"HAPROXY_GROUP": "my_group", "HAPROXY_0_BACKEND_HTTP_OPTIONS": " option forwardfor\n http-request set-header X-Forwarded-Port %[dst_port]\n http-request add-header X-Forwarded-Proto https if { ssl_fc }\n acl is_my_rewrite_domain hdr(host) -i my_rewrite_domain\n reqrep ^([^\\ ]*)\\ /my-path(.*) \\1\\ /my-path/api\\2 if is_my_rewrite_domain\n", "HAPROXY_0_PATH": "-i /my-path", "HAPROXY_0_VHOST": "my_domain,my_rewrite_domain"

Then in backend will replace the path.

Da-Hong avatar Mar 10 '17 09:03 Da-Hong