History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CC-541
Type: Bug Bug
Status: Open Open
Priority: Critical Critical
Assignee: Jeffrey Fredrick
Reporter: Benjamin Francisoud
Votes: 5
Watchers: 6
Operations

If you were logged in you would be able to see more operations.
CruiseControl

[PATCH] Make Cruisecontrol accessible via a Proxy

Created: 25/Oct/06 08:08 AM   Updated: 03/Jun/08 11:11 AM
Component/s: Reporting Application
Affects Version/s: 2.6
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. Text File patch-03-nov-2006-CC-541-03.patch (43 kb)
2. Zip Archive patch-03-nov-2006-CC-541-03.zip (193 kb)
3. Zip Archive patch-25-oct-2006-CC-541-02.zip (187 kb)
4. Text File patch-25-oct-2006-CC-541.patch (38 kb)
5. Zip Archive patch-25-oct-2006-CC-541.zip (183 kb)

Issue Links:
Relationship
This issue Relates to:
CC-293 Web pages embedding base URL means ma... Major Open
This issue Relates to:
CC-192 JMX console IP Address Binding Major Open


 Description  « Hide
The CC-293 issue is quite a comments'mess so I prefer to open an other one just for the patch and link it to CC-293.


-------------------------------------------
Introduction
-------------------------------------------
So this patch has 3 different parts:
* Replace canonical URL (http://host:port/context) with url link /context to adapt to any hostname (proxy or not proxy)
* In cases (rss.jsp for example) where we really need full canonical url, use a new class that extract the proxy hostname

from special headers
* Make jmx available behind a proxy

-------------------------------------------
How I tested my patch:
-------------------------------------------
* Tested with both context / and /cruisecontrol
* Tested with localhost:8080
* Tested behind an apache mod_proxy using ssl but cruisecontrol jetty was no using ssl (Help to see tricky problems with

request.getScheme())

I ran ant (default target: release). Unit tests are ok, checkstyle too..

-------------------------------------------
Proxy configuration:
-------------------------------------------
{noformat}
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

# Warning the ProxyPath order is important
# JMX proxy configuration
ProxyPass /cruisecontrol/jmx http://localhost:8000
ProxyPassReverse /cruisecontrol/jmx http://localhost:8000

# Html pages configuration
ProxyPass /cruisecontrol http://localhost:8080/cruisecontrol
ProxyPassReverse /cruisecontrol http://localhost:8080/cruisecontrol
{noformat}

-------------------------------------------
Details
-------------------------------------------
- First point "replace canonical urls":
I really think this <base href> think is the worst invention of html ever (I already had problems with it in a previous

project)
The only way to get clean/always working urls is to remove this <base href> and use contextPath/img/foo.gif urls.
That's what I did and tested everywhere and in different conditions.
I had to change some custom tags to return "contextPath aware" url (ArtifactsLinkTag and TabSheetTag)

- Second point "use canonical url behind proxy" mainly rss.jsp:
More complex, I created a URLProxyResolver.java (and it's unit test) to extract special headers added by mod_proxy.
That means my patch only works for Apache (tested on apache 2.2) but since that's the most use proxy that would fix 90% of

"people using proxy"'s problems.
URLProxyResolver use a new class HttpServletRequestWrapper that appeared in servlet 2.4, that means I need to replace

servlet.jar to servlet-api-2.4.jar + jsp-api-2.0.jar (Sun splited the jar)
Since in servlet-api-2.4 have new methods in some interfaces (Request, Response...), I needed to add those new methods to

the mock objects under net.sourceforge.cruisecontrol.mock
I added code in rss.jsp to check if request is proxied, if true use the proxy hostname to create url.
There is still a problem in rss when the proxy is using ssl, url will use cruisecontrol scheme (don't know how to fix that

but that not the common case)

- Third point "jmx available behind a proxy":
User need to setup their proxy with the above parameters "/cruisecontrol/jmx" thing.
I used my new class URLProxyResolver to check if request is behind a proxy, if true, url will be like

/contextPath/jmx/[mbean|invoke]
If not we use the normal jmx url http://localhost:8000/[mbean|invoke]
It work I can force a build via the proxy and watch/set param in the jmx bean in controlpanel.


-------------------------------------------
Conclusion
-------------------------------------------
I know this is a big patch but please give it a try.
I putted lots of efforts in it :( and I really think I didn't broke anything :)
Still if you find any bug please let me know...

I will add a svn-diff text file for the patch and a zip file with all the modified files + the new jars (since they will not appear in the svn-diff text file)

 All   Comments   Work Log   Change History      Sort Order:
No work has yet been logged on this issue.