HAProxy community

Basic redirection to fixed uri


#1

I’m new to HAProxy and looking to simply re-direct http traffic to Tomcat on the same server - will add conditional logic latter.

Pertinent config includes:
frontend http_front
bind *:8082 # Port HAProxy uses
default_backend http_back

backend http_back
mode http
server localhost 127.0.0.1:8080 # Port used by Apache Tomcat

The redirect should go to http://127.0.0.1:8080/static/test.html which is served by Tomcat

I’ve tried various formats using the “redirect” and “http-request set-uri” commands to no avail. Any suggestions are appreciated.


#2

Are you actually wanting to return a redirect to the user that points to http://127.0.0.1:8080/static/test.html, or do you want to change the url in the request to the backend?


#3

Change URI in request to backend


#4

You should be able to do that with something like:

http-request set-path /static/test.html