Dear HAProxy Developers:
We have a PHP application server at product1.local.domain. We are able
to access it within company’s internal network via Apache Web server.
We would like to access it via public Web server at http://external.dom
through the gateway to the application server at http://<FQDN>/product1/.
This application server links to itself at many places. In the request
generated by the application server, the /product1 in path is replaced
with / by the application. Those links need to be rewritten to work
through the gateway to make it accessible from outside.
Such as rewrite http://product1.local.domain /*.php to
http://<FQDN>/product1/*.php.
This is same as what Apache server’s mod_proxy_html serves to:
rewrite <a href="http://appserver.example.com/foo/bar.html">foobar</a>
to <a href="http://www.example.com/appserver/foo/bar.html">foobar</a>.
Is there an output filter equivalent of Apache server’s mod_proxy_html
in HAProxy to rewrite internal links in:
(i) a PHP page?
(ii) an HTML page?
Example is Rewrite condition: If the application links to self, then
Rewrite rule:
Below are our
(1) relevant code of PHP application
(2) HAProxy configuration and
(3) logs.
The logs show,
(i) HTTP code=304 till line #4
(ii) the prefix /product1 gets deleted after line#4 (see line #5 in
logs) and hence gets redirected to default backend (HTTP code = 503).
How could we change the HTTP request to include prefix /product1 to the
rest of the path for all connections?
++++++++++++++++++++++++DETAILS+++++++++++++++++
+++++++++
(1) PHP Application
++++++++
<link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
<link rel=stylesheet href="../themes/login.css" type="text/css">
...
<frameset rows="<?php echo
"$GLOBALS[logoBarHeight],$GLOBALS[titleBarHeight]" ?>,*" cols="*"
frameborder="NO" border="0" framespacing="0">
<frame class="logobar" src="<?php echo $rootdir;?>/login/filler.php"
name="Filler Top" scrolling="no" noresize frameborder="NO">
<frame class="titlebar" src="<?php echo
$rootdir;?>/login/login_title.php" name="Title" scrolling="no" noresize
frameborder="NO">
<frame src="<?php echo $rootdir;?>/login/login.php" name="Login"
scrolling="auto" frameborder="NO">
</frameset>
+++++++
(2) HAProxy configuration
+++++++
In logs, the prefix /product1 gets deleted after a few lines (see line#4
in logs below). How could we change the HTTP request to include prefix
/product1 to the rest of the path for all connections?
http-request set-header Host <SERVER_IP:APPLICATION_PORT>
reqirep ^([^\ ]*)\ /Product1/?([^\ ]*)\ (.*)$ \1\ /\2\ \3
acl hdr_location res.hdr(Location) -m found
rspirep ^Location:\
(https?://Product1.vm0.internal.domain(:[0-9]+)?)?(/.*) Location:\
/Product1\3 if hdr_location
#cookie
acl hdr_set_cookie_dom res.hdr(Set-cookie) -m sub Domain=
Product1.vm0.coscend.local
rspirep ^(Set-Cookie:.*)\ Domain=Product1.vm0.internal.domain(.*)
\1\ Domain=<FQDN>\2 if hdr_set_cookie_dom
acl hdr_set_cookie_path res.hdr(Set-cookie) -m sub Path=
rspirep ^(Set-Cookie:.*)\ Path=(.*) \1\ Path=/Product1\2 if
hdr_set_cookie_path
server Product1.vm0 Product1.vm0.internal.domain:80 cookie p1-p check
+++++++
(3) Info.Log
+++++++
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET
/Product1/interface/login/login_frame.php?site=default HTTP/1.1" 200
1159 "" "" 62551 160 "webapps-frontend~" "subdomain_p1-backend"
"Product1.vm0" 28 0 1 13 42 ---- 1 1 0 1 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET
/Product1/interface/login/login_frame.php?site=default HTTP/1.1" 200
1159 "" "" 62551 160 "webapps-frontend~" "subdomain_p1-backend"
"Product1.vm0" 28 0 1 13 42 ---- 1 1 0 1 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /Product1/interface/themes/login.css
HTTP/1.1" 304 129 "" "" 62551 202 "webapps-frontend~"
"subdomain_p1-backend" "Product1.vm0" 10 0 1 0 11 ---- 1 1 0 1 0 0 0 "" ""
#4: Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /Product1/interface/themes/login.css
HTTP/1.1" 304 129 "" "" 62551 202 "webapps-frontend~"
"subdomain_p1-backend" "Product1.vm0" 10 0 1 0 11 ---- 1 1 0 1 0 0 0 "" ""
#5: Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/filler.php HTTP/1.1"
503 213 "" "" 62551 214 "webapps-frontend~" "webapps-backend" "<NOSRV>"
2 -1 -1 -1 2 SC-- 2 2 0 0 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/filler.php HTTP/1.1"
503 213 "" "" 62551 214 "webapps-frontend~" "webapps-backend" "<NOSRV>"
2 -1 -1 -1 2 SC-- 2 2 0 0 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/login_title.php
HTTP/1.1" 503 213 "" "" 62557 222 "webapps-frontend~" "webapps-backend"
"<NOSRV>" 4 -1 -1 -1 4 SC-- 3 3 0 0 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/login_title.php
HTTP/1.1" 503 213 "" "" 62557 222 "webapps-frontend~" "webapps-backend"
"<NOSRV>" 4 -1 -1 -1 4 SC-- 3 3 0 0 0 0 0 "" ""
=-=-=-=-=-=-=-
Thank you.
Sincerely,
-- --
Susheel Jalali
Coscend Communications Solutions
Susheel.Jalali@Coscend.com
www.Coscend.com
-------------------------------------
We have a PHP application server at product1.local.domain. We are able
to access it within company’s internal network via Apache Web server.
We would like to access it via public Web server at http://external.dom
through the gateway to the application server at http://<FQDN>/product1/.
This application server links to itself at many places. In the request
generated by the application server, the /product1 in path is replaced
with / by the application. Those links need to be rewritten to work
through the gateway to make it accessible from outside.
Such as rewrite http://product1.local.domain /*.php to
http://<FQDN>/product1/*.php.
This is same as what Apache server’s mod_proxy_html serves to:
rewrite <a href="http://appserver.example.com/foo/bar.html">foobar</a>
to <a href="http://www.example.com/appserver/foo/bar.html">foobar</a>.
Is there an output filter equivalent of Apache server’s mod_proxy_html
in HAProxy to rewrite internal links in:
(i) a PHP page?
(ii) an HTML page?
Example is Rewrite condition: If the application links to self, then
Rewrite rule:
Below are our
(1) relevant code of PHP application
(2) HAProxy configuration and
(3) logs.
The logs show,
(i) HTTP code=304 till line #4
(ii) the prefix /product1 gets deleted after line#4 (see line #5 in
logs) and hence gets redirected to default backend (HTTP code = 503).
How could we change the HTTP request to include prefix /product1 to the
rest of the path for all connections?
++++++++++++++++++++++++DETAILS+++++++++++++++++
+++++++++
(1) PHP Application
++++++++
<link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
<link rel=stylesheet href="../themes/login.css" type="text/css">
...
<frameset rows="<?php echo
"$GLOBALS[logoBarHeight],$GLOBALS[titleBarHeight]" ?>,*" cols="*"
frameborder="NO" border="0" framespacing="0">
<frame class="logobar" src="<?php echo $rootdir;?>/login/filler.php"
name="Filler Top" scrolling="no" noresize frameborder="NO">
<frame class="titlebar" src="<?php echo
$rootdir;?>/login/login_title.php" name="Title" scrolling="no" noresize
frameborder="NO">
<frame src="<?php echo $rootdir;?>/login/login.php" name="Login"
scrolling="auto" frameborder="NO">
</frameset>
+++++++
(2) HAProxy configuration
+++++++
In logs, the prefix /product1 gets deleted after a few lines (see line#4
in logs below). How could we change the HTTP request to include prefix
/product1 to the rest of the path for all connections?
http-request set-header Host <SERVER_IP:APPLICATION_PORT>
reqirep ^([^\ ]*)\ /Product1/?([^\ ]*)\ (.*)$ \1\ /\2\ \3
acl hdr_location res.hdr(Location) -m found
rspirep ^Location:\
(https?://Product1.vm0.internal.domain(:[0-9]+)?)?(/.*) Location:\
/Product1\3 if hdr_location
#cookie
acl hdr_set_cookie_dom res.hdr(Set-cookie) -m sub Domain=
Product1.vm0.coscend.local
rspirep ^(Set-Cookie:.*)\ Domain=Product1.vm0.internal.domain(.*)
\1\ Domain=<FQDN>\2 if hdr_set_cookie_dom
acl hdr_set_cookie_path res.hdr(Set-cookie) -m sub Path=
rspirep ^(Set-Cookie:.*)\ Path=(.*) \1\ Path=/Product1\2 if
hdr_set_cookie_path
server Product1.vm0 Product1.vm0.internal.domain:80 cookie p1-p check
+++++++
(3) Info.Log
+++++++
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET
/Product1/interface/login/login_frame.php?site=default HTTP/1.1" 200
1159 "" "" 62551 160 "webapps-frontend~" "subdomain_p1-backend"
"Product1.vm0" 28 0 1 13 42 ---- 1 1 0 1 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET
/Product1/interface/login/login_frame.php?site=default HTTP/1.1" 200
1159 "" "" 62551 160 "webapps-frontend~" "subdomain_p1-backend"
"Product1.vm0" 28 0 1 13 42 ---- 1 1 0 1 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /Product1/interface/themes/login.css
HTTP/1.1" 304 129 "" "" 62551 202 "webapps-frontend~"
"subdomain_p1-backend" "Product1.vm0" 10 0 1 0 11 ---- 1 1 0 1 0 0 0 "" ""
#4: Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /Product1/interface/themes/login.css
HTTP/1.1" 304 129 "" "" 62551 202 "webapps-frontend~"
"subdomain_p1-backend" "Product1.vm0" 10 0 1 0 11 ---- 1 1 0 1 0 0 0 "" ""
#5: Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/filler.php HTTP/1.1"
503 213 "" "" 62551 214 "webapps-frontend~" "webapps-backend" "<NOSRV>"
2 -1 -1 -1 2 SC-- 2 2 0 0 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/filler.php HTTP/1.1"
503 213 "" "" 62551 214 "webapps-frontend~" "webapps-backend" "<NOSRV>"
2 -1 -1 -1 2 SC-- 2 2 0 0 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/login_title.php
HTTP/1.1" 503 213 "" "" 62557 222 "webapps-frontend~" "webapps-backend"
"<NOSRV>" 4 -1 -1 -1 4 SC-- 3 3 0 0 0 0 0 "" ""
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - -
[30/Oct/2015:23:25:42 +0000] "GET /interface/login/login_title.php
HTTP/1.1" 503 213 "" "" 62557 222 "webapps-frontend~" "webapps-backend"
"<NOSRV>" 4 -1 -1 -1 4 SC-- 3 3 0 0 0 0 0 "" ""
=-=-=-=-=-=-=-
Thank you.
Sincerely,
-- --
Susheel Jalali
Coscend Communications Solutions
Susheel.Jalali@Coscend.com
www.Coscend.com
-------------------------------------