Gian Honório
Gian Honório

Reputation: 63

Redirect on HAProxy

I'm trying to replicate the following configuration made in apache in HAProxy, but so far without success.

<VirtualHost *:80>
    ProxyPreserveHost On
    ServerName alpha.app.int
    ProxyPass / http://127.0.0.1:8080/app/
    ProxyPassReverse / http://127.0.0.1:8080/app/
</VirtualHost>

What I'm trying to do is when the address 'alpha.app.int' is accessed, HAProxy automatically directs all requests for my application in JBoss that is listening on '127.0.0.1:8080/app/', but when I try to access through the url previously mentioned I end up falling on the configuration screen of JBoss and not in my application, I can only see it by accessing 'alpha.app.int/app/'. Does anyone have any suggestions on how to do this?

HAProxy Settings:

frontend app
    bind *:80
    mode http
    default_backend frontend app

backend app
    mode http
    option forwardfor
    server alpha 127.0.0.1:8080/app

Upvotes: 1

Views: 2390

Answers (1)

Olivier PALANQUE
Olivier PALANQUE

Reputation: 156

You can try that :

frontend app
    bind *:80
    acl path_root path /
    redirect location https://www.example.com/app/ if path_root
    default_backend             app

backend app
    mode http
    option forwardfor
    server alpha 127.0.0.1:8080

Upvotes: 1

Related Questions