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)