Skip to content

Instantly share code, notes, and snippets.

@ramr
Created April 25, 2016 21:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramr/0559d1d3aa538ad6370571c488984cfd to your computer and use it in GitHub Desktop.
Save ramr/0559d1d3aa538ad6370571c488984cfd to your computer and use it in GitHub Desktop.
haproxy-config-host-remove-port-rule
[ramr@localhost origin (cached:master:c-0:s-0+224:o-6126)]$ git stash show stash@{3} -p
diff --git a/images/router/haproxy/conf/haproxy-config.template b/images/router/haproxy/conf/haproxy-config.template
index eb5b565..0f4e999 100644
--- a/images/router/haproxy/conf/haproxy-config.template
+++ b/images/router/haproxy/conf/haproxy-config.template
@@ -60,6 +60,7 @@ listen stats :1936
frontend public
bind :{{env "ROUTER_SERVICE_HTTP_PORT" "80"}}
mode http
+ http-request replace-value Host (.*):.* \1
tcp-request inspect-delay 5s
tcp-request content accept if HTTP
@@ -84,6 +85,7 @@ frontend public
# that terminates encryption in this router (edge)
frontend public_ssl
bind :{{env "ROUTER_SERVICE_HTTPS_PORT" "443"}}
+ http-request replace-value Host (.*):.* \1
tcp-request inspect-delay 5s
tcp-request content accept if { req_ssl_hello_type 1 }
@plewin
Copy link

plewin commented Oct 3, 2018

thank you, this was helpful to me

@tarucan
Copy link

tarucan commented Nov 10, 2018

not working to me

@wkgcass
Copy link

wkgcass commented Nov 21, 2018

great! works fine for me on ha 1.6

@vinivasundharan
Copy link

I am trying to remove a custom port from my URL. I have added 'http-request replace-value Host (.*):9080 \1', but still the port is not removed from the url. I have it in my http-in frontend and also in my custom backend.

@vinivasundharan
Copy link

great! works fine for me on ha 1.6

Are you trying to put the url redirection on http or a custom port?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment