0

I have simple haproxy configuration: two servers, one is frontend, two is backend with jboss application. Here is config:

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    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  proxy
    bind 192.168.2.1:443 ssl crt /etc/ssl/certs/certificate.pem
    default_backend             jboss
backend jboss
    #redirect scheme https if !{ ssl_fc }
    server      jboss 192.168.1.1:8080 check

I want to simplify url. Now if I want to enter to webapp I must type subdirectory in url https:// www.example.com/webapp/

I want to enter https:// www.example.com and haproxy will serve me page from http://192.168.1.1:8080/webapp. How to do this?

3
  • Do you want HAproxy to rewrite the requests, or redirect the user?
    – GregL
    Aug 6, 2015 at 11:32
  • Have you tried Nginx?
    – Anatoly
    Aug 6, 2015 at 12:21
  • @GregL Initially I want to rewrite requests but links to graphics on webapp have absolute path. Problem was solved by redirecting from root to subdirectory.
    – QkiZ
    Aug 7, 2015 at 7:57

1 Answer 1

1

Problem solved by adding redirect in frontend section.

frontend  proxy
    bind 192.168.2.1:443 ssl crt /etc/ssl/certs/certificate.pem
    acl path_root path /
    redirect location https://www.example.com/webapp/ if path_root
    default_backend             jboss

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.