Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4715

How to keep urlpath the same in the browser, while reverse proxying

$
0
0

@sinaowolabi wrote:

Hi!

I am pretty new to haproxy and I would love some help in figuring out how to properly use reqirep and rspirep syntax.

I have a group of backend servers, each with the same https://bak_srv:8443/backend root URL path, but each server is for a different external user groups. :8443/backend is a tomcat application.

I would like each user group to be able to connect to the same haproxy service, say https://haproxy/group{1,2,3}, and redirect each group to their backend server, but without changing the haproxy URL. For instance, group one should always see https://haproxy/group1(/.*), and haproxy should proxy pages and information from https://bak_srv1:8443/backend(/.*).

Currently the rules I have in place are:

frontend group1-in

    bind *:443 ssl crt /usr/local/etc/haproxy/ssl/domain.pem
    option http-server-close
    option forwardfor
    reqadd X-Forwarded-Proto:\ https
    reqadd X-Forwarded-Port:\ 443
    rspadd  Strict-Transport-Security:\ max-age=15768000
    default_backend group1-in-backend`

backend group1-in-backend
    stats enable
    stats auth admin:admin
    stats uri /haproxy?stats
    # ^GET /group1(.*) HTTP/1.0$, should be seen by group1_serv as /backend(.*)
    reqirep ^([^\ ]*)\ /group1/([^\ ]*)\ (.*)$       \1\ /backend\2\ \3
    #if response contains Location: header, reinsert the application name in its value
    rspirep ^(Location:)\ https://([^/]*)/(.*)$    \1\ https://\2/backend/\3
    #set cookies
    rspirep ^(Set-Cookie:.*\ path=)([^\ ]+)(.*)$       \1/group1\2\3    
    server group1_serv bak_srv_1:8443 ssl verify none`

but these rules arent working due to my poor understanding of reqirep and rspirep.
Please can someone show me what I am doing wrong?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4715

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>