Re: How to Externally Access PHP Application that has Internal Links to Itself

2015-11-04 Thread Susheel Jalali

Dear Aleks,

As you advised, in the file ../Product1/interface/globals.php, we
(a) Reviewed Line 137/138.  This takes the value from Line 67/68.
(b) Conducted two tests.
Here are the results.  We would appreciate any vector to solve this 
external access via HAProxy issue.


TEST CASE 1:
With the original product1 code, we are able to access it within 
company’s internal network via local DNS.  But we cannot access the 
product externally through HAProxy.


In logs, the prefix /product1 gets deleted after a few lines (see line#4 
in logs below) in internal hyperlinks of the product.



Output on page = /interface

TEST CASE 2:
When we manually input the path as below, we are able to access the 
product externally through HAProxy.  But we cannot access it within 
company’s internal network via local DNS.


In logs below, the prefix /Product1 appears in internal hyperlinks of 
the product.


   Line 67:$webserver_root = "/usr/local/Product1";
   Line 68:$web_root =  "/Product1";


Output on page = /product1/interface

+++
HAProxy configuration
+++
http-request set-header Host 
reqirep ^([^\ ]*)\ /Product1/?([^\ ]*)\ (.*)$   \1\ /\2\ \3
acl hdr_location res.hdr(Location) -m found
rspirep ^Location:\ 
(https?://)(Product1).vm0.internal.domain(:[0-9]+)?(/.*)?(.*) 
Location:\/\2\3\4 if hdr_location
#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.internal.domain
rspirep ^(Set-Cookie:.*)\ Domain=Product1.vm0.internal.domain(.*) 
\1\ Domain=\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

+++
Info.Log

CASE 1:  With the original product code, we are able to access it within 
company’s internal network via local DNS.  But we cannot access the 
product externally through HAProxy.
Oct 30 18:25:42 localhost haproxy[18120]: 192.168.100.153 - - 
[30/Oct/2015:23:25:42 +] "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 +] "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 +] "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 +] "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 +] "GET /interface/login/filler.php HTTP/1.1" 
503 213 "" "" 62551 214 "webapps-frontend~" "webapps-backend" "" 
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 +] "GET /interface/login/filler.php HTTP/1.1" 
503 213 "" "" 62551 214 "webapps-frontend~" "webapps-backend" "" 
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 +] "GET /interface/login/login_title.php 
HTTP/1.1" 503 213 "" "" 62557 222 "webapps-frontend~" "webapps-backend" 
"" 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 +] "GET /interface/login/login_title.php 
HTTP/1.1" 503 213 "" "" 62557 222 "webapps-frontend~" "webapps-backend" 
"" 4 -1 -1 -1 4 SC-- 3 3 0 0 0 0 0 "" ""


-
CASE 2:  When we manually input the path, we are able to access the 
product externally through HAProxy.  But we cannot access it within 
company’s internal network via local DNS.

The prefix /Product1 appears in internal hyperlinks of the product1.
Nov  4 13:07:30 localhost haproxy[5246]: 192.168.100.153 - - 
[04/Nov/2015:19:07:30 +] "GET /Product1/ HTTP/1.1" 302 235 "" "" 
63715 211 "webapps-frontend~" "subdomain_p1-backend" "Product1.vm0" 35 0 
0 1 36  1 1 0 1 0 0 0 "" ""
Nov  4 13:07:30 localhost haproxy[5246]: 192.168.100.153 - - 
[04/Nov/2015:19:07:30 +] "GET /Product1/ HTTP/1.1" 302 235 "" "" 
63715 211 "webapps-frontend~" "subdomain_p1-backend" "Product1.vm0" 35 0 
0 1 36  1 1 0 1 0 0 0 "" ""
Nov  4 13:07:30 localhost haproxy[5246]: 192.168.100.153 - - 

Re: How to Externally Access PHP Application that has Internal Links to Itself

2015-11-02 Thread Aleksandar Lazic

Dear Susheel Jalali

Am 02-11-2015 20:24, schrieb Susheel Jalali:

Dear Aleks,


[snipp]


We modified this solution (of Apache) to work with HAProxy, but did
not succeed.  Is there any insight anyone could provide?


What have you changed?
Please post your current config.


+++
Internal Hyperlinks in our PHP page:
+++
,*" cols="*"
frameborder="NO" border="0" framespacing="0">
   
   
   



please add  to the PHP page and post the 
output.


You have not answered if my Assumption was right!

I still assume that you try to run

http://open-emr.org

therefore please take a look into this code.

https://github.com/openemr/openemr/blob/8b9d250de3c76aeb4f706342c2f3c3f1e1b9c6db/interface/globals.php#L137

https://github.com/openemr/openemr/blob/8b9d250de3c76aeb4f706342c2f3c3f1e1b9c6db/interface/globals.php#L38

Best regards
Aleks


On 10/31/15 14:36, Aleksandar Lazic wrote:

Dear Susheel Jalali.

Am 31-10-2015 08:43, schrieb Susheel Jalali:

Dear HAProxy Developers:


[snipp]


This is same as what Apache server’s mod_proxy_html serves to:
rewrite href="http://appserver.example.com/foo/bar.html;>foobar


to href="http://www.example.com/appserver/foo/bar.html;>foobar.


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?


Assumption:

you use http://open-emr.org

conclusion:

http://www.open-emr.org/wiki/index.php/Apache2_Notes

follow up

http://blog.haproxy.com/2014/04/28/howto-write-apache-proxypass-rules-in-haproxy/ 
Have I assumed right and was you able to step forward?


BR Aleks






RE: How to Externally Access PHP Application that has Internal Links to Itself

2015-11-02 Thread Susheel Jalali

Dear Aleks,

Apologies we missed answering one of your previous questions.

I still assume that you try to run http://open-emr.org

We have three products written in PHP and HTML5.  All of these are 
facing similar issues due to relative hyperlinks to itself.   One of 
these is OpenEMR, whose code we posted.  We will work on the others 
after we succeed here.


We are working on the two pointers you provided and will share with you 
later today:


(i)   openemr/../globals.php and

(ii)   output.

(iii) current HAProxy config


Thank you.

Sincerely,
--

Susheel Jalali

www.Coscend.com


 Original Message 
From: Aleksandar Lazic 
Date: Mon, November 02, 2015 11:30 pm
Dear Susheel Jalali

Am 02-11-2015 20:24, schrieb Susheel Jalali:
> Dear Aleks,

[snipp]

> We modified this solution (of Apache) to work with HAProxy, but did
> not succeed. Is there any insight anyone could provide?

What have you changed?
Please post your current config.

> +++
> Internal Hyperlinks in our PHP page:
> +++
>  "$GLOBALS[logoBarHeight],$GLOBALS[titleBarHeight]" ?>,*" cols="*"
> frameborder="NO" border="0" framespacing="0">
>  $rootdir;?>/login/filler.php" name="Filler Top" scrolling="no"
> noresize frameborder="NO">
>  $rootdir;?>/login/login_title.php" name="Title" scrolling="no"
> noresize frameborder="NO">
> /login/login.php" name="Login"
> scrolling="auto" frameborder="NO">
> 

please add  to the PHP page and post the
output.

You have not answered if my Assumption was right!

I still assume that you try to run

http://open-emr.org

therefore please take a look into this code.

https://github.com/openemr/openemr/blob/8b9d250de3c76aeb4f706342c2f3c3f1e1b9c6db/interface/globals.php#L137

https://github.com/openemr/openemr/blob/8b9d250de3c76aeb4f706342c2f3c3f1e1b9c6db/interface/globals.php#L38

Best regards
Aleks

> On 10/31/15 14:36, Aleksandar Lazic wrote:
>> Dear Susheel Jalali.
>>
>> Am 31-10-2015 08:43, schrieb Susheel Jalali:
>>> Dear HAProxy Developers:
>>
>> [snipp]
>>
>>> This is same as what Apache server’s mod_proxy_html serves to:
>>> rewrite >>> href="http://appserver.example.com/foo/bar.html;>foobar
>>
>>> to >>> href="http://www.example.com/appserver/foo/bar.html;>foobar.
>>
>>> 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?
>>
>> Assumption:
>>
>> you use http://open-emr.org
>>
>> conclusion:
>>
>> http://www.open-emr.org/wiki/index.php/Apache2_Notes
>>
>> follow up
>>
>> 
http://blog.haproxy.com/2014/04/28/howto-write-apache-proxypass-rules-in-haproxy/ 


>> Have I assumed right and was you able to step forward?
>>
>> BR Aleks
>>



Re: How to Externally Access PHP Application that has Internal Links to Itself

2015-11-02 Thread Susheel Jalali

Dear Aleks,

Thank you for the information.  We implemented your insights (i.e., 
http://blog.haproxy.com/2014/04/28/howto-write-apache-proxypass-rules-in-haproxy/). 
It only rewrites the URL in the address bar.  The PHP application has 
internal hyperlinks in each page (see frameset, frame class in the code 
below) .


In the request generated by the application server, the /product1 in 
path is replaced with / by the PHP application.  Those links need to be 
rewritten to work through HAProxy to make it accessible from outside.  
Here is an example of how internal links are being rewritten for proxy 
by Apache HTTP server: 
http://serverfault.com/questions/222823/phpapache-as-forward-reverse-proxy-how-to-process-client-requests-and-server-r?answertab=active#tab-top


This is same as what Apache server’s mod_proxy_html serves to:
rewrite http://appserver.example.com/foo/bar.html;>foobar
to http://www.example.com/appserver/foo/bar.html;>foobar.

We modified this solution (of Apache) to work with HAProxy, but did not 
succeed.  Is there any insight anyone could provide?


+++
Internal Hyperlinks in our PHP page:
+++
,*" cols="*" 
frameborder="NO" border="0" framespacing="0">
   name="Filler Top" scrolling="no" noresize frameborder="NO">
   frameborder="NO">
   scrolling="auto" frameborder="NO">




Thank you.

Sincerely,

Susheel Jalali

www.Coscend.com
On 10/31/15 14:36, Aleksandar Lazic wrote:

Dear Susheel Jalali.

Am 31-10-2015 08:43, schrieb Susheel Jalali:

Dear HAProxy Developers:


[snipp]


This is same as what Apache server’s mod_proxy_html serves to:
rewrite http://appserver.example.com/foo/bar.html;>foobar



to http://www.example.com/appserver/foo/bar.html;>foobar.



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?


Assumption:

you use http://open-emr.org

conclusion:

http://www.open-emr.org/wiki/index.php/Apache2_Notes

follow up

http://blog.haproxy.com/2014/04/28/howto-write-apache-proxypass-rules-in-haproxy/ 



Have I assumed right and was you able to step forward?

BR Aleks







Re: How to Externally Access PHP Application that has Internal Links to Itself

2015-10-31 Thread Aleksandar Lazic

Dear Susheel Jalali.

Am 31-10-2015 08:43, schrieb Susheel Jalali:

Dear HAProxy Developers:


[snipp]


This is same as what Apache server’s mod_proxy_html serves to:
rewrite http://appserver.example.com/foo/bar.html;>foobar
to http://www.example.com/appserver/foo/bar.html;>foobar.
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?


Assumption:

you use http://open-emr.org

conclusion:

http://www.open-emr.org/wiki/index.php/Apache2_Notes

follow up

http://blog.haproxy.com/2014/04/28/howto-write-apache-proxypass-rules-in-haproxy/

Have I assumed right and was you able to step forward?

BR Aleks