I'm looking for a solution to redirect GET/POST HTTP requests on a server.

The easy part would be port translation and hostname redirection (HTTP 3xx redirection): When my server in a DMZ receives traffic on port 7070 (http://mydmz.server.com:7070), it would redirect the traffic to a public web server (http://liveupdate.symantecliveupdate.com on default port 80)

But It also needs to modify on the fly request headers:

  • /clu-prod should get stripped from the URI
  • Host: mydmz.server.com should be replaced by Host: liveupdate.symantecliveupdate.com

What tool, solutions could I use on a server to listen on port 7070 and do the following ? A load balancer, a HTTP proxy ?

enter image description here enter image description here

1 Answer 1


I think you can achieve this with HAProxy.

  • Set it to listen port 7070/tcp in httpd mode.
  • modify host header with haproxy replace-value. In your case it could be like:

    http-request replace-value Host mydmz.server.com:(.*) liveupdate.symantecliveupdate.com:\1
  • strip URI with haproxy url rewriting. In you case this could be something like:

    reqrep ^([^\ ]*\ /)clu-prod[/]?(.*)     \1\2

With those settings your HAProxy configuration could look something like this (this is quickly modified from HAProxy default config in CentOS 7, this is not tested thoroughly):

   log local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    stats socket /var/lib/haproxy/stats

    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

frontend  main *:7070
    default_backend             app

backend app
    http-request replace-value Host mydmz.server.com:(.*) liveupdate.symantecliveupdate.com:\2
    reqrep ^(.*)/clu-prod(.*) \1/\2
    balance     roundrobin
    server  app1 liveupdate.symantecliveupdate.com:80 check

Other option you maybe could use is squid proxy http://www.squid-cache.org/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.