Koozali.org: home of the SME Server

Customizing httpd.conf with rewrite rules

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #15 on: April 09, 2005, 09:19:41 AM »
I thought I'd tried the RewriteRule, but couldn't get the expand template process to work correctly - although I can't recall if I tried single quotes.

Is there an advantage to using it instead of ProxyPass? None of the reading I've done really clarifies that.

Regards,

Des
Des Dougan

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #16 on: April 09, 2005, 04:26:33 PM »
Des,

With 'ProxyPass / http://localhost... etc' the url 'www.douganconsulting.com' and 'www.douganconsulting.com/directory/subdirectory/' get interpreted the same way (the /directory/subdirectory/ portion is ignored). This is not the case with 'RewriteRule ^/(.*)http.../$1' The $1 variable causes the subdirectory portions to be appended to the url that gets sent to Plone.

For simple Plone usage the difference is irrelevant. However, you may get to a situation that needs it. With ProxyPass you will be stuck.

John
...

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #17 on: April 09, 2005, 05:49:47 PM »
John,

Thanks! I'll take a look at it and test it on my test system.

Regards,

Des
Des Dougan

Offline chris burnat

  • *****
  • 1,135
  • +2/-0
    • http://www.burnat.com
Customizing httpd.conf with rewrite rules
« Reply #18 on: April 23, 2005, 08:13:40 AM »
Hello,
Sorry to barge in.  I have to install plone2 and zope for a site at the uni on Sydney, trying to find a howto, no luck so far - Des post on the forum dated 26 May get a "not found" return.  I have found Des rpms (2004/6/2), are they still valid for 6.1?  Can you assist and point me in the right direction?
Many thanks regards chris
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.

Offline chris burnat

  • *****
  • 1,135
  • +2/-0
    • http://www.burnat.com
Customizing httpd.conf with rewrite rules
« Reply #19 on: April 23, 2005, 08:15:18 AM »
Quote from: "burnat"
Hello,
Sorry to barge in.  I have to install plone2 and zope for a site at the uni, trying to find a howto, no luck so far - Des post on the forum dated 26 May get a "not found" return.  I have found Des rpms (2004/6/2), are they still valid for 6.1?  Can you assist and point me in the right direction?
Many thanks regards chris
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #20 on: April 23, 2005, 08:17:51 AM »
As far as I know, they will work for 6.x - there's been little change since 6.0.

Des
Des Dougan

Offline chris burnat

  • *****
  • 1,135
  • +2/-0
    • http://www.burnat.com
Customizing httpd.conf with rewrite rules
« Reply #21 on: April 23, 2005, 09:54:50 AM »
Thanks for this, any Howto around that you know about?
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #22 on: April 23, 2005, 09:32:04 PM »
The following is what I used and it seemed to work. It presumes that you are going to have two Plone sites - one public facing and an intranet site for local staff. If you are not going to have the intranet site, forget about the extra i-bay and don't bother creating the second Plone Site instance.

Also, I found that if I set up Plone against my Primary i-bay, I couldn't get at my server-manager panel. So I have an i-bay called 'main' and set up a domain (e.g., 'mydomain.ca') for that (the SME server's domain I call 'primary.mydomain.ca' to avoid confusion).

Here's my How-To

Install Plone
Before you start, ensure that none of the domains to be served by Plone are the Primary. Set up an I-bay for the main web site and one for the intranet site; and set up virtual domains for each.

Download Des Dougan’s rpms
login as root

Create a directory for the downloads
Code: [Select]
# mkdir –p /root/downloads/smeplone
# cd /root/downloads/smeplone


Download the files
Code: [Select]
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/Plone2-2.0.2-sme.04.i386.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/Plone2-2.0.2-sme.04.src.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/db4-4.1.25-0.rh73.3.1.i386.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/db4-devel-4.1.25-0.rh73.3.1.i386.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/expat-1.95.5-2.i386.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/python2.3-2.3.3-2pydotorg.i386.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/python2.3-2.3.3-2pydotorg.src.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/python2.3-devel-2.3.3-2pydotorg.i386.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/python2.3-docs-2.3.3-2pydotorg.i386.rpm
# wget –nc http://mirror.contribs.org/smeserver/contribs/ddougan/Plone/python2.3-tools-2.3.3-2pydotorg.i386.rpm


Install Plone
Code: [Select]
# rpm –Uvh db4*
# rpm –Uvh python*
# rpm –Uvh expat*
# rpm –Uvh Plone*


Start Plone
Code: [Select]
# /etc/rc.d/init.d/plone2 start

Test Plone
Code: [Select]
# lynx “http://localhost:9080/Plone”
You should see the Plone main page in text browser mode.

Setup ‘Virtual Host Monster’
The Des Dougan rpms seem to set the initial administrative Plone/Zope userid to 'plone' with a password of 'plone'.
Quote
From a network attached Windows computer, open a ssh tunnel with the target server
using PuTTY:

On the ‘Session’ pane, enter the ip address of the server and on the SSH>Tunnels pane, enter ‘9080’ as the Source Port and ‘127.0.0.1:9080’ as the Destination, the push the ‘Add’ button. This information should then appear in the Forwarded Ports box. Click the Open button at the bottom to open a session on the server.

Login as ‘root’ with the root password


OR

Quote
From a Linux workstation, open a ssh tunnel using the ssh command
in a terminal window enter

ssh -L 9080:localhost:9080 -C 192.168.0.1 -f sleep 100000

Be sure to replace the ‘192.168.0.1’ with the ip address of the server.

Then:

Open a web browser with the address ‘127.0.0.1:9080/manage’

The Zope main page should display. On the upper right of the screen, select “Virtual Host Monster” from the Add pull-down list, and push the Add button. In the form that opens, enter an id (use ‘vhm’).

Then, setup a second Plone instance for the intranet site.

On the upper right of the Zope main page, select “Plone Site” from the Add pull-down list and push the Add button. In the form that opens, enter an id (use ‘Intranet’); add a Title (e.g., ‘Company Intranet Site’); keep the default Membership source and provide a Description (e.g., ‘The Company intranet site.’) Then click Add Plone Site and wait for the site to be created.

Close the browser and the ssh tunnel.

Setup Apache virtual host routing to the VHM
Ensure that this directory path exists

/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts

and if not, create it.
Code: [Select]
# mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts

Change to that directory.

Code: [Select]
# cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts

create an empty file
Code: [Select]
# pico

add the following lines to the file:

Code: [Select]
#
# RewriteRule directives for Zope/Plone Virtual Host Monster
#
RewriteEngine on
{
return “” unless $virtualHost eq “mainhost.ca”;
‘RewriteRule ^/(.*) http://localhost:9080/VirtualHostBase/http/[ip]:80/Plone/VirtualHostRoot/$1 [L.P]’;
}
{
return “” unless $virtualHost eq “intranet.mainhost.ca”;
‘RewriteRule ^/(.*) http://localhost:9080/VirtualHostBase/http/[ip]:80/Intranet/VirtualHostRoot/$1 [L.P]’;
}


Replace the ‘[ip]’ portion with the relevant domain name (e.g., www.mainhost.ca) and save with the file name ‘35Rewrite’

N.B. ensure that each RewriteRule directive is only on one line before saving and enclosed in single quotes.

then regenerate the Apache configuration file
Code: [Select]
# /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

then restart Apache to have the new configuration take effect
Code: [Select]
# service httpd restart

Get Plone to start automatically on boot.

Code: [Select]
# cd /etc/rc.d
# pico rc.local


add to the bottom of the file

Code: [Select]
# start Plone2
/etc/rc.d/init.d/plone2 start

save and exit

And that's it. Using a browser go to your Plone domain and try it.

Best of luck.

John
...

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Customizing httpd.conf with rewrite rules
« Reply #23 on: April 23, 2005, 09:38:31 PM »
Quote from: "wjhobbs"

With 'ProxyPass / http://localhost... etc' the url 'www.douganconsulting.com' and 'www.douganconsulting.com/directory/subdirectory/' get interpreted the same way (the /directory/subdirectory/ portion is ignored).


No, that's not true. The server-manager wouldn't work, if that were the case, and neither would my friend's website, which is proxypassed through my server to his.

I have a custom template .../httpd.conf/ProxyPassVirtualHosts/template-begin containing:

    ServerName www.{$virtualHost}
    ServerAlias { "$virtualHost  $SystemName.$virtualHost" }
{
    use esmith::DomainsDB;
    my $db = esmith::DomainsDB->open_ro;
    my $d = $db->get($virtualHost);
    my $t = $d->prop('ProxyPassTarget');

    $OUT = "    ProxyPass / $t";
}

<VirtualHost {$ipAddress}:{$port}>
</VirtualHost>

and his domain database entry is:

host.domain=domain
    Content=Primary
    Description=xxxxxx
    ProxyPassTarget=http://a.b.c.d/
    TemplatePath=ProxyPassVirtualHosts

His domain gets way more traffic than any of mine, and has always worked perfectly.

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #24 on: April 23, 2005, 10:01:22 PM »
Charlie,

Sorry if I was not clear. What I was referring to was the way in which Des had his ProxyPass directive defined. In that one, there was no variable substitution and therefore there appeared to be no way to allow for the subdirectories to be appended to the specified url. Everything got passed to his plone site root regardless.

John
...

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Customizing httpd.conf with rewrite rules
« Reply #25 on: April 24, 2005, 02:51:55 AM »
Quote from: "wjhobbs"

Sorry if I was not clear. What I was referring to was the way in which Des had his ProxyPass directive defined. In that one, there was no variable substitution and therefore there appeared to be no way to allow for the subdirectories to be appended to the specified url.


There is no variable substitution in a ProxyPass  directive. ProxyPass only translates URL prefixes. Anything in the URL after the translated prefix is included in the proxied request. See:

http://www.linuxfocus.org/English/March2000/article147.html
http://httpd.apache.org/docs-2.0/mod/mod_proxy.html


Quote

Everything got passed to his plone site root regardless.


Perhaps there some issue specific to plone. I'm sure the full URL is passed on.

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #26 on: April 24, 2005, 07:45:28 AM »
You basically install the RPMs and use the information that the installation provides (e.g. port number 9080). If you plan to make the installation available to the outside world, you'll need an Apache ProxyPass or Rewrite rule - search here for both, There's a good bit of information on them.

Des
Des Dougan

Offline chris burnat

  • *****
  • 1,135
  • +2/-0
    • http://www.burnat.com
Customizing httpd.conf with rewrite rules
« Reply #27 on: April 24, 2005, 03:57:55 PM »
Many thanks John. I have so far managed to install, and from a windows box establish an ssh tunel and accessed the zope page.  Now I am stuck...May I ask a couple of questions:

1) Total ignorance of my part, how do you type the character  “”  in the 35Rewrite file??

2) Is my syntax correct, All I will use if the WAN side, no intranet.  The domain is strumpf.com with an IP 203.47.55.211.
Is this correct:

#
# RewriteRule directives for Zope/Plone Virtual Host Monster
#
RewriteEngine on
{
return “” unless $virtualHost eq “stumpf.com”;
‘RewriteRule ^/(.*) http://localhost:9080/VirtualHostBase/http/203.47.55.211:80/Plone/VirtualHostRoot/$1 [L.P]’;
}

Many thanks, chris.
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #28 on: April 26, 2005, 07:28:25 PM »
Chris,

The "" is in fact a double-quote immediately followed by a double-quote.

Your RewriteRule looks OK to me except that I put the domain name instead of the ip address (i.e., replace the 203.47.55.211:80 with stumpf.com:80)

John
...