Dear Wiki user, You have subscribed to a wiki page or wiki category on "Lenya Wiki" for change notification.
The following page has been changed by JanHo: http://wiki.apache.org/lenya/HowToModProxy ------------------------------------------------------------------------------ + This page refers to version 1.2.x - The {{{org.apache.lenya.cms.cocoon.transformation.LinkRewritingTransformer}}} class enables a flexible way of proxy configuration. It is possible to define a proxy for each area / SSL combination. The proxy configuration happens in {{{$PUBLICATION/config/publication.xconf}}}. You also have to setup the frontend apache webserver accordingly. Otherwise you will end up with only dead links. - There are two usecases described in this How-To: A very simple setup and a more complex one: + = Existing documentation on reverse proxying = - == Configuration == - If you install lenya, a publication.xconf of the default publication looks as follows: - {{{ - <publication> - <languages> - <language default="true">en</language> - <language>de</language> - </languages> - <path-mapper>org.apache.lenya.cms.publication.DefaultDocumentIdToPathMapper</path-mapper> - <document-builder>org.apache.lenya.cms.publication.DefaultDocumentBuilder</document-builder> - <breadcrumb-prefix/> - <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@href"/> - <!-- - <proxy area="live" ssl="true" url="https://www.host.com/ssl/default"/> - <proxy area="live" ssl="false" url="http://www.host.com/default"/> - <proxy area="authoring" ssl="true" url="https://www.host.com/lenya/default/authoring"/> - <proxy area="authoring" ssl="false" url="http://www.host.com/lenya/default/authoring"/> - --> - </publication> - }}} - i.e no proxy is configured and lenya URL's work "out of the box". + This is a list of the existing documentation on proxying: + * [http://lenya.apache.org/docs/1_2_x/tutorial/mod_proxy_and_lenya.html Part 6a: mod_proxy and Lenya] + * [http://lenya.apache.org/docs/1_2_x/tutorial/mod_proxy_and_lenya_continued.html Part 6b: mod_proxy and Lenya] + * [http://lenya.apache.org/docs/1_2_x/components/deployment/proxying.html Reverse Proxying Apache Lenya] - == Simple Setup == - If you just want to map your live site to a host having URL's like http://www.yourpub.com/index.html you should first define a proxy like: - {{{ - <proxy area="live" ssl="false" url="http://www.yourpub.com"/> - }}} - In order to Map the cms live server into this URL space you have to define mod_proxy directive as follows: - {{{ - <VirtualHost www.yourpub.com:80> - ..... - ProxyPass / http://localhost:8080/yourpub/live/ - ProxyPassReverse / http://localhost:8080/yourpub/live/ - # this is needed for css, etc. - RewriteRule ^/yourpub/live(.*)$ $1 [R] - </VirtualHost> - }}} - Basically that's it. [[BR]] - '''Note:'''[[BR]] - {{{The abov rules assume that lenya is deployed under the ROOT context which is the default - if you use jetty but not if you use tomcat.}}} - - == A more complex setup == - - A possible configuration for two servers (an authoring server and a live server) may look like: - {{{ - <publication> - <languages> - <language default="true">de</language> - <language>en</language> - </languages> - <path-mapper>org.apache.lenya.cms.publication.DefaultDocumentIdToPathMapper</path-mapper> - <document-builder>org.apache.lenya.cms.publication.DefaultDocumentBuilder</document-builder> - <breadcrumb-prefix>Universit?t Zuerich</breadcrumb-prefix> - <proxy url="https://cms.sandox.live.ch" ssl="true" area="live"/> - <proxy url="http://cms.sandbox.live.ch" ssl="false" area="live"/> - <proxy url="https://cms.authoring.ch/lenya/sandbox/authoring" ssl="true" area="authoring"/> - <proxy url="http://cms.authoring.ch/lenya/sandbox/authoring" ssl="false" area="authoring"/> - </publication> - }}} - That means: - * There is an ssl enabled authoring server (cms.authoring.ch) and the URL you get is e.g. {{{http://cms.authoring.com/lenya/sandbox/authoring/index.html}}}. - * There is an ssl enabled live server with (cms.live.ch and cms.sandbox.live.ch) and the URL you get on the live side is e.g. {{{http://cms.sandbox.live.ch/lenya/index.html}}} - '''Note:'''[[BR]] - {{{Up to now, session is only working if you add /lenya after your domain because the cookie which is - sent to the client stores the web application context. Therefore the browser did not send back the cookie - if you request a page like http://cms.sandbox.live.ch/index.html. - This is also mentioned on http://wiki.apache.org/cocoon/ApacheModProx.}}} - - With Apache 2.1 a recently introduced proxy directive for translating the cookie path {{{ProxyPassReverseCookiePath}}} will be available, which will allow you to get the cookie path translated by Apache with - {{{ProxyPassReverseCookiePath /lenya /}}} so that the cookie is always sent back to the server. - - As of today even the HEAD version of 2.0 does not have this feature. If you still want to use it with Apache 2.0 you will have to apply a patch [http://issues.apache.org/bugzilla/show_bug.cgi?id=10722] and rebuild the Apache modules mod_proxy and mod_http_proxy. The patch should work with Apache 2.0.49+ (I use it with 2.0.52 without any problems). - - As an ALTERNATIVE to patching Apache one might install Lenya within the ROOT context, because then Cookie will contain "/" instead of "/lenya" and it will work with the common mod_proxy settings. Note that you'll have to adjust the proxy rules to get rid of "/lenya" in this case. If you run Jetty, which runs Lenya in the ROOT context, you'll have to remove the "/lenya" parts as well. - - Another solution might be to use Squid! - - The configuration of the Apache webserver goes with this configuration is described next - - == Apache Webserver setup / Rewrite Rules == - === Rules for the authoring server cms.authoring.ch === - - * redirects logins to SSL - * assumes Tomcat, with Lenya running under /lenya (for Jetty, remove /lenya from the configuration) - * runs the authoring server over port 80 - * publications are all mounted under cms.client.com/yourpub - * you can use this setup for your live server if you do not want to mount your publication in a virtualhost. just replace authoring with live, and put the proxy / rewrite directives in a <Location> rule - {{{ - <VirtualHost cms.authoring.ch:80> - .... - - #All Content should be served by tomcat (i.e. lenya) - ProxyRequests Off - RewriteEngine On - RewriteLog /var/log/apache2/cms.authoring.rewrite.log - RewriteLogLevel 0 - RewriteRule ^/([^/\.]+)$ $1/ [R] - RewriteRule ^/([^/\.]+)/$ http://cms.authoring.ch/lenya/$1/authoring/index.html [R,L] - - RewriteCond %{QUERY_STRING} lenya\.usecase=login(.*) - RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L] - - RewriteRule ^/(.*) http://cms.authoring.ch:8080/$1 [P,L] - ProxyPassReverse / http://cms.authoring.ch:8080/ - - </VirtualHost> - - <VirtualHost cms.authoring.ch:443> - .... - RewriteEngine On - - RewriteRule ^/([^/\.]+)$ $1/ [R] - RewriteRule ^/([^/\.]+)/$ http://cms.authoring.ch/lenya/$1/authoring/index.html [R,L] - - RewriteRule ^/(.*) http://%{SERVER_NAME}:8080/$1 [P,L] - ProxyPassReverse / http://cms.authoring.ch:8080/ - </VirtualHost> - }}} - - === Rules for the Live Server (cms.sandbox.live.ch)> === - * The live publication is deployed under the ROOT context (i.e. no /lenya prefix) - * The publication is based on the unicms publication (some {{{RewriteRules}}} may slightly differ for publications based on the default publication). - * each publication is mounted as a seperate virtualhost - * Files within the directory static and files with the extension php are not redirected to the cms. - * assumes Tomcat, with Lenya running under /lenya (for Jetty, remove /lenya from the configuration) - * Certificate is issued for www.client.com - {{{ - <VirtualHost cms.sandbox.live.ch:80> - .... - - ProxyRequests Off - RewriteEngine On - - # The first to Rules ensure that php Files (*.php) or pages with /static in the URL will be - # directly handled by the webserver - RewriteRule ^/(.*)\.php(?:\?.*)?$ $0 [L] - RewriteRule ^/static/(.*) $0 [L] - - RewriteRule ^/$ /index.html [R] - RewriteRule ^/(.*\.css$) http://cms.live.ch:8080/$1 [P,L] - RewriteRule ^/(.*/authoring/.*) http://cms.live.ch:8080/$1 [P,L] - RewriteRule ^/[^/]+/live/(.*)$ /$1 [R,L] - - # If you use Lenya-wide resources (e.g. in the 404 page), this rule is needed as well: - RewriteRule ^/lenya/lenya/(.*) http://cms.live.ch:8080/lenya/lenya/$1 [P] - - # Main rule for publication content - RewriteRule ^/(.*) http://cms.live.ch:8080/sandbox/live/$1 [P] - - # Rule for search area - RewriteRule ^/lenya/(.*)/search-live/(.*)$ http://cms.live.ch:8080/lenya/$1/search-live/$2 [P] - - ProxyPassReverse / http://cms.live.ch:8080/ - - </VirtualHost> - - <VirtualHost cms.live.ch:443> - ...... - - ProxyRequests Off - RewriteEngine On - - # RewriteRules for css and images - RewriteRule ^/lenya/unizh/(.*)/images/(.*)$ http://cms.live.ch:8080/lenya/unizh/$1/images/$2 [P,L] - RewriteRule ^/(.*\.css$) http://cms.live.ch:8080/$1 [P,L] - - RewriteRule ^/(lenya/[^/]+)/(.*)$ http://cms.live.ch:8080/$1/live/$2 [P,L] - - # Rule for search area - RewriteRule ^/lenya/(.*)/search-live/(.*)$ http://cms.live.ch:8080/lenya/$1/search-live/$2 [P] - - ProxyPassReverse / http://cms.live.ch:8080/ - </VirtualHost> - }}} - --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
