You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by "Linczak, Jonathan W." <Li...@hiram.edu> on 2005/03/19 19:48:02 UTC

mod_proxy question

Hi all,

While studying up on your mod_proxy how-to document (located here: http://wiki.apache.org/lenya/HowToModProxy), I couldn't figure out one statement on there.  Right before the sample configuration is given for the Authoring server, it's mentioned that you could use the same configuration for your live server if you don't want to mount them all as separate virtual hosts.

To do this, just change all instances of the word "authoring" to "live", and wrap the rewrites and proxy line in a <Location> directive.  Perhaps this is an Apache question, but why would you have to wrap it in a <Location> directive?  Would the results look like this?:

<VirtualHost cms.live.ch:80>
    ....

    #All Content should be served by tomcat (i.e. lenya)
    ProxyRequests    Off
    RewriteEngine    On
    RewriteLog       /var/log/apache2/cms.live.rewrite.log
    RewriteLogLevel  0

    <Location />
        RewriteRule      ^/([^/\.]+)$  $1/   [R]
        RewriteRule       ^/([^/\.]+)/$ http://cms.authoring.ch/lenya/$1/live/index.html [R,L]

        # Removed query string because not needed for live section??

        RewriteRule      ^/(.*)   http://cms.live.ch:8080/$1  [P,L]
        ProxyPassReverse / http://cms.live.ch:8080/
    </Location>

</VirtualHost>

<VirtualHost cms.live.ch:443>
   ....
    ProxyRequests Off
    RewriteEngine On

    <Location />
        RewriteRule      ^/([^/\.]+)$  $1/   [R]
        RewriteRule       ^/([^/\.]+)/$ http://cms.live.ch/lenya/$1/live/index.html [R,L]

        RewriteRule      ^/(.*)   http://%{SERVER_NAME}:8080/$1  [P,L]
        ProxyPassReverse / http://cms.live.ch:8080/
    </Location>

</VirtualHost>


Thanks for any help you can pass along...

Jon

Re: mod_proxy question

Posted by Jann Forrer <ja...@id.unizh.ch>.
On Tue, 22 Mar 2005, Josias Thoeny wrote:

> On Tue, 2005-03-22 at 11:55 -0500, Jonathan Linczak wrote:
> > On Mar 22, 2005, at 11:41 AM, Jann Forrer wrote:
> >
> > > On Tue, 22 Mar 2005, Jonathan Linczak wrote:
> > >
> > >> On Mar 22, 2005, at 4:46 AM, Jann Forrer wrote:
> > >>
> > > [ ... ]
> > >>
> > >> Good catch, I will definitely have to update my article to note this.
> > >> When I set this up, I didn't update the publication.xconf file
> > >> appropriately, so I always stayed in SSL.  Of course, as I've noted
> > >> before in other mailings, I have always had trouble getting that to
> > >> work properly.  Now that a fresh install of 1.2.2 is available for me
> > >> to do testing, I'll try it again to see if this works.
> > >>
> > >
> > > As far as i know the LinkRewriting did not work properly for "older
> > > lenya
> > > versions" ( < 1.2.2 ) but it works for lenya => 1.2.2.
> > > However if you deploy lenya under the ROOT context you will have
> > > difficulties because the context prefix is hardcode in the urls like
> > > /lenya/sandbox/authoring/foo.html
> > >
> > > http://issues.apache.org/bugzilla/show_bug.cgi?id=31157
> >
> > Well that's no fun... I would assume the solution is to just put it
> > under the "lenya" directory, but I can still remove all the other
> > webapps that come installed by default in Tomcat.  I can't seem to
> > follow the discussion too well on the bug report, but it seems as if
> > Josias has put together something that solves this problem for 1.4-dev?
>
> It's only a partial solution...
> I wrote an ant task to migrate content, i.e. replace the context prefix
> of the links. (Well, basically you could do that with a simple shell
> script, too)
> If you have a different prefix in the authoring server than in the live
> server, you have to migrate the content every time you publish a
> document (or wait until this is really fixed in Lenya).
> Currently the version attached in bugzilla is not working because the
> Lenya API has changed since I wrote it.
> I think I have a version for 1.2.x somewhere, if you want to try it I
> can post it.
>

I have a workaround for our live server which runs under the ROOT context
whereas the authoring Server runs in the lenya context ending in URL like
/lenya/sandbox/authoring/foo.html

Note that this patch is not a real fix of the problem but only a simple
temporary workaround (e.g.hardcoded lenya) until this is really fixed in
lenya:

Index: LinkRewritingTransformer.java
===================================================================
--- LinkRewritingTransformer.java	(revision 154149)
+++ LinkRewritingTransformer.java	(working copy)
@@ -190,9 +190,14 @@

                     String context = this.request.getContextPath();

-                    if (href.startsWith(context + "/" +
publication.getId())) {
+                    if ((href.startsWith(context + "/" +
publication.getId())) || (href.startsWith("/lenya/"+
publication.getId()))) {

-                        final String webappUrlWithAnchor =
href.substring(context.length());
+                    	String webappUrlWithAnchor =
href.substring(context.length());
+                    	if  (href.startsWith("/lenya/"+
publication.getId())) {
+                    		String lenyaprefix="/lenya";
+                    	    webappUrlWithAnchor =
href.substring(lenyaprefix.length());
+                    	}
+

                         String anchor = null;
                         String webappUrl = null;


HTH

Jann

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: mod_proxy question

Posted by Josias Thoeny <jo...@wyona.com>.
On Tue, 2005-03-22 at 11:55 -0500, Jonathan Linczak wrote:
> On Mar 22, 2005, at 11:41 AM, Jann Forrer wrote:
> 
> > On Tue, 22 Mar 2005, Jonathan Linczak wrote:
> >
> >> On Mar 22, 2005, at 4:46 AM, Jann Forrer wrote:
> >>
> > [ ... ]
> >>
> >> Good catch, I will definitely have to update my article to note this.
> >> When I set this up, I didn't update the publication.xconf file
> >> appropriately, so I always stayed in SSL.  Of course, as I've noted
> >> before in other mailings, I have always had trouble getting that to
> >> work properly.  Now that a fresh install of 1.2.2 is available for me
> >> to do testing, I'll try it again to see if this works.
> >>
> >
> > As far as i know the LinkRewriting did not work properly for "older 
> > lenya
> > versions" ( < 1.2.2 ) but it works for lenya => 1.2.2.
> > However if you deploy lenya under the ROOT context you will have
> > difficulties because the context prefix is hardcode in the urls like
> > /lenya/sandbox/authoring/foo.html
> >
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=31157
> 
> Well that's no fun... I would assume the solution is to just put it 
> under the "lenya" directory, but I can still remove all the other 
> webapps that come installed by default in Tomcat.  I can't seem to 
> follow the discussion too well on the bug report, but it seems as if 
> Josias has put together something that solves this problem for 1.4-dev?

It's only a partial solution...
I wrote an ant task to migrate content, i.e. replace the context prefix
of the links. (Well, basically you could do that with a simple shell
script, too)
If you have a different prefix in the authoring server than in the live
server, you have to migrate the content every time you publish a
document (or wait until this is really fixed in Lenya).
Currently the version attached in bugzilla is not working because the
Lenya API has changed since I wrote it. 
I think I have a version for 1.2.x somewhere, if you want to try it I
can post it.

Josias

> Jon
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: mod_proxy question

Posted by Jonathan Linczak <li...@hiram.edu>.
On Mar 22, 2005, at 11:41 AM, Jann Forrer wrote:

> On Tue, 22 Mar 2005, Jonathan Linczak wrote:
>
>> On Mar 22, 2005, at 4:46 AM, Jann Forrer wrote:
>>
> [ ... ]
>>
>> Good catch, I will definitely have to update my article to note this.
>> When I set this up, I didn't update the publication.xconf file
>> appropriately, so I always stayed in SSL.  Of course, as I've noted
>> before in other mailings, I have always had trouble getting that to
>> work properly.  Now that a fresh install of 1.2.2 is available for me
>> to do testing, I'll try it again to see if this works.
>>
>
> As far as i know the LinkRewriting did not work properly for "older 
> lenya
> versions" ( < 1.2.2 ) but it works for lenya => 1.2.2.
> However if you deploy lenya under the ROOT context you will have
> difficulties because the context prefix is hardcode in the urls like
> /lenya/sandbox/authoring/foo.html
>
> http://issues.apache.org/bugzilla/show_bug.cgi?id=31157

Well that's no fun... I would assume the solution is to just put it 
under the "lenya" directory, but I can still remove all the other 
webapps that come installed by default in Tomcat.  I can't seem to 
follow the discussion too well on the bug report, but it seems as if 
Josias has put together something that solves this problem for 1.4-dev?

Jon


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: mod_proxy question

Posted by Jann Forrer <ja...@id.unizh.ch>.
On Tue, 22 Mar 2005, Jonathan Linczak wrote:

> On Mar 22, 2005, at 4:46 AM, Jann Forrer wrote:
>
[ ... ]
>
> Good catch, I will definitely have to update my article to note this.
> When I set this up, I didn't update the publication.xconf file
> appropriately, so I always stayed in SSL.  Of course, as I've noted
> before in other mailings, I have always had trouble getting that to
> work properly.  Now that a fresh install of 1.2.2 is available for me
> to do testing, I'll try it again to see if this works.
>

As far as i know the LinkRewriting did not work properly for "older lenya
versions" ( < 1.2.2 ) but it works for lenya => 1.2.2.
However if you deploy lenya under the ROOT context you will have
difficulties because the context prefix is hardcode in the urls like
/lenya/sandbox/authoring/foo.html

http://issues.apache.org/bugzilla/show_bug.cgi?id=31157

Jann

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: mod_proxy question

Posted by Jonathan Linczak <li...@hiram.edu>.
On Mar 22, 2005, at 4:46 AM, Jann Forrer wrote:

> I read your article with great interest. I have some 
> comments/questions. I
> am not quite sure about your restrictions described under "A caveat o 
> SSL"
> having two different domains or sub-domains with SSL ports opend.
> <VirtualHost *:80>
>     ServerName lenya.client.com
>     ServerAlias ......
>     ......
> </VirtualHost
>
>
> <VirtualHost *:80>
>     ServerName www.client.com
>     ServerAlias ......
>     ......
> </VirtualHost>
>
> Is not possbile to have  a similar setup for port 443 have two 
> different
> certificates for lenya.client.com and www.client.com?

Thanks, Jann, for taking the time to read the article.  According to 
documentation from Apache, and from my own experiences, this indeed is 
not possible within the same Apache instance without either using 
another IP address for the second SSL site, or using a different port.  
The explanation is found in the Apache documentation, located here: 
http://httpd.apache.org/docs-2.0/ssl/ssl_faq.html#vhosts2.  I've tried 
this myself before finding the explanation of why it's not working.


> A note on login and ssl: You will not stay in SSL for all your editing
> after login if you configure your publication (in publication.xconf)
> accordingly:
>
> <publication>
>   .....
>   .....
> <!--[B
>   <proxy area="live" ssl="true" 
> url="https://cms.unizh.ch/lenya/unitemplate/live"/>
>   <proxy area="live" ssl="false" 
> url="http://cms.unizh.ch/lenya/unitemplate/live"/>
> -->
>   <proxy area="authoring" ssl="true" 
> url="https://lenya.client.com/default/authoring"/>
>   <proxy area="authoring" ssl="false" 
> url="http://lenya.client.com/default/authoring"/>
> </publication>
>
> That means after login you will be in https but as soon as you use a 
> link
> in the authoring tab you will be redirected to http (the
> LinkRewritingTransformer will take care of that).

Good catch, I will definitely have to update my article to note this.  
When I set this up, I didn't update the publication.xconf file 
appropriately, so I always stayed in SSL.  Of course, as I've noted 
before in other mailings, I have always had trouble getting that to 
work properly.  Now that a fresh install of 1.2.2 is available for me 
to do testing, I'll try it again to see if this works.

Jon


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: mod_proxy question

Posted by Jann Forrer <ja...@id.unizh.ch>.
On Mon, 21 Mar 2005, Jonathan Linczak wrote:


[ ... ]
>
> Hi Ken,
>
> You're right - I was misreading that.  That only means then that I was
> doing for the live server is still the suggested way for the setup I
> have, so that's nice to know.  :)  If anyone's interested, I put
> together part "A" of an article on the mod_proxy setup for Lenya, but
> when you install Lenya under the ROOT context in Tomcat.  You can find
> the article here: http://redarrow.textdrive.com/.  Please give me your
> thoughts on the article!  :)
>

I read your article with great interest. I have some comments/questions. I
am not quite sure about your restrictions described under "A caveat o SSL"
having two different domains or sub-domains with SSL ports opend.
<VirtualHost *:80>
    ServerName lenya.client.com
    ServerAlias ......
    ......
</VirtualHost


<VirtualHost *:80>
    ServerName www.client.com
    ServerAlias ......
    ......
</VirtualHost>

Is not possbile to have  a similar setup for port 443 have two different
certificates for lenya.client.com and www.client.com?

A note on login and ssl: You will not stay in SSL for all your editing
after login if you configure your publication (in publication.xconf)
accordingly:

<publication>
  .....
  .....
<!--[B
  <proxy area="live" ssl="true" url="https://cms.unizh.ch/lenya/unitemplate/live"/>
  <proxy area="live" ssl="false" url="http://cms.unizh.ch/lenya/unitemplate/live"/>
-->
  <proxy area="authoring" ssl="true" url="https://lenya.client.com/default/authoring"/>
  <proxy area="authoring" ssl="false" url="http://lenya.client.com/default/authoring"/>
</publication>

That means after login you will be in https but as soon as you use a link
in the authoring tab you will be redirected to http (the
LinkRewritingTransformer will take care of that).

Jann

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: mod_proxy question

Posted by Jonathan Linczak <li...@hiram.edu>.
On Mar 20, 2005, at 2:02 AM, Ken Gunderson wrote:

> On Sat, 19 Mar 2005 13:48:02 -0500
> "Linczak, Jonathan W." <Li...@hiram.edu> wrote:
>
>> Hi all,
>>
>> While studying up on your mod_proxy how-to document (located here: 
>> http://wiki.apache.org/lenya/HowToModProxy), I couldn't figure out 
>> one statement on there.  Right before the sample configuration is 
>> given for the Authoring server, it's mentioned that you could use the 
>> same configuration for your live server if you don't want to mount 
>> them all as separate virtual hosts.
>
>
> Hi Jon:
>
> I read it differently-- it says if you do not want to mount your pub in
> a vhost.  Hence you must be mounting them in your "main server" config.
>
>> To do this, just change all instances of the word "authoring" to 
>> "live", and wrap the rewrites and proxy line in a <Location> 
>> directive.  Perhaps this is an Apache question, but why would you 
>> have to wrap it in a <Location> directive?  Would the results look 
>> like this?:
>>
>> <VirtualHost cms.live.ch:80>
>>     ....
>>
>>     #All Content should be served by tomcat (i.e. lenya)
>>     ProxyRequests    Off
>>     RewriteEngine    On
>>     RewriteLog       /var/log/apache2/cms.live.rewrite.log
>>     RewriteLogLevel  0
>>
>>     <Location />
>>         RewriteRule      ^/([^/\.]+)$  $1/   [R]
>>         RewriteRule       ^/([^/\.]+)/$ 
>> http://cms.authoring.ch/lenya/$1/live/index.html [R,L]
>>
>>         # Removed query string because not needed for live section??
>>
>>         RewriteRule      ^/(.*)   http://cms.live.ch:8080/$1  [P,L]
>>         ProxyPassReverse / http://cms.live.ch:8080/
>>     </Location>
>>
>> </VirtualHost>
>>
>> <VirtualHost cms.live.ch:443>
>>    ....
>>     ProxyRequests Off
>>     RewriteEngine On
>>
>>     <Location />
>>         RewriteRule      ^/([^/\.]+)$  $1/   [R]
>>         RewriteRule       ^/([^/\.]+)/$ 
>> http://cms.live.ch/lenya/$1/live/index.html [R,L]
>>
>>         RewriteRule      ^/(.*)   http://%{SERVER_NAME}:8080/$1  [P,L]
>>         ProxyPassReverse / http://cms.live.ch:8080/
>>     </Location>
>>
>> </VirtualHost>
>>
>>
>> Thanks for any help you can pass along...
>>
>> Jon
>>
>
> Since you are mounting in a vhost with the config you outline above, I
> would say the <Location> directives are not necessary.  Unless you have
> a mixed site comprised of lenya and non lenya docs.  In which case you
> want to adjust your rewrite rules accordingly so as to foward http
> requests as appropriate.
>
> If you do intend to mount the pubs in you main server, then you should
> ditch the vhost config block all together.  Then the <Location>
> directives can go near the end of you config file and will rewrite
> anything coming into your www.my.dom to point to the live area of your
> lenya pub, sans the long url.

Hi Ken,

You're right - I was misreading that.  That only means then that I was 
doing for the live server is still the suggested way for the setup I 
have, so that's nice to know.  :)  If anyone's interested, I put 
together part "A" of an article on the mod_proxy setup for Lenya, but 
when you install Lenya under the ROOT context in Tomcat.  You can find 
the article here: http://redarrow.textdrive.com/.  Please give me your 
thoughts on the article!  :)

Jon


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: mod_proxy question

Posted by Ken Gunderson <kg...@teamcool.net>.
On Sat, 19 Mar 2005 13:48:02 -0500
"Linczak, Jonathan W." <Li...@hiram.edu> wrote:

> Hi all,
> 
> While studying up on your mod_proxy how-to document (located here: http://wiki.apache.org/lenya/HowToModProxy), I couldn't figure out one statement on there.  Right before the sample configuration is given for the Authoring server, it's mentioned that you could use the same configuration for your live server if you don't want to mount them all as separate virtual hosts.


Hi Jon:

I read it differently-- it says if you do not want to mount your pub in
a vhost.  Hence you must be mounting them in your "main server" config.
 
> To do this, just change all instances of the word "authoring" to "live", and wrap the rewrites and proxy line in a <Location> directive.  Perhaps this is an Apache question, but why would you have to wrap it in a <Location> directive?  Would the results look like this?:
> 
> <VirtualHost cms.live.ch:80>
>     ....
> 
>     #All Content should be served by tomcat (i.e. lenya)
>     ProxyRequests    Off
>     RewriteEngine    On
>     RewriteLog       /var/log/apache2/cms.live.rewrite.log
>     RewriteLogLevel  0
> 
>     <Location />
>         RewriteRule      ^/([^/\.]+)$  $1/   [R]
>         RewriteRule       ^/([^/\.]+)/$ http://cms.authoring.ch/lenya/$1/live/index.html [R,L]
> 
>         # Removed query string because not needed for live section??
> 
>         RewriteRule      ^/(.*)   http://cms.live.ch:8080/$1  [P,L]
>         ProxyPassReverse / http://cms.live.ch:8080/
>     </Location>
> 
> </VirtualHost>
> 
> <VirtualHost cms.live.ch:443>
>    ....
>     ProxyRequests Off
>     RewriteEngine On
> 
>     <Location />
>         RewriteRule      ^/([^/\.]+)$  $1/   [R]
>         RewriteRule       ^/([^/\.]+)/$ http://cms.live.ch/lenya/$1/live/index.html [R,L]
> 
>         RewriteRule      ^/(.*)   http://%{SERVER_NAME}:8080/$1  [P,L]
>         ProxyPassReverse / http://cms.live.ch:8080/
>     </Location>
> 
> </VirtualHost>
> 
> 
> Thanks for any help you can pass along...
> 
> Jon
> 

Since you are mounting in a vhost with the config you outline above, I
would say the <Location> directives are not necessary.  Unless you have
a mixed site comprised of lenya and non lenya docs.  In which case you
want to adjust your rewrite rules accordingly so as to foward http
requests as appropriate.

If you do intend to mount the pubs in you main server, then you should
ditch the vhost config block all together.  Then the <Location>
directives can go near the end of you config file and will rewrite
anything coming into your www.my.dom to point to the live area of your
lenya pub, sans the long url.

-- 
Best regards,

Ken Gunderson
GPG Key-- 9F5179FD

"Freedom begins between the ears."	-- Edward Abbey


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org