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
« on: January 23, 2005, 11:39:16 PM »
I recently realized that I have an error in  my httpd.conf file - I'd added a template fragment in the VirtualHosts custom directory (35Rewrite). However, it's in the wrong place, as it's affecting all my virtual domains, rather than the main domain as I want. However, I can't work out where to place it in the template hierarchy such that the Rewrite rules affect only one domain instead of the three domains I have on my server. The rule is for my Plone site (RewriteRule ^/(.*) http://localhost:9080/VirtualHostBase/http/www.DouganConsulting.com:80/Plone/VirtualHostRoot/$1 [L,P])

Can anyone point me in the right direction?

Thanks,
Des Dougan

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Customizing httpd.conf with rewrite rules
« Reply #1 on: January 30, 2005, 05:09:36 PM »
Quote from: "ddougan"
I recently realized that I have an error in  my httpd.conf file - I'd added a template fragment in the VirtualHosts custom directory (35Rewrite). However, it's in the wrong place, as it's affecting all my virtual domains, rather than the main domain as I want. However, I can't work out where to place it in the template hierarchy such that the Rewrite rules affect only one domain instead of the three domains I have on my server. The rule is for my Plone site (RewriteRule ^/(.*) http://localhost:9080/VirtualHostBase/http/www.DouganConsulting.com:80/Plone/VirtualHostRoot/$1 [L,P])

Can anyone point me in the right direction?

Thanks,


Put some code in the template to make the output conditional. Something like:

{
  return "" unless $virtualHost eq "one.that.i.want";
  "RewriteRule ^/(.*) ...";
}

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #2 on: January 30, 2005, 05:16:50 PM »
Many thanks, Charlie. I'll give that a try.

Des
Des Dougan

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #3 on: February 03, 2005, 06:53:18 AM »
Charlie,

I've been testing your suggestion (with quotes around the entire rule, followed by the semi-colon, per your example). When I expanded the template, I get a warning like this:

WARNING in /etc/e-smith/templates-custom//etc/httpd/conf/httpd.conf/VirtualHosts/35Rewrite: Use of uninitialized value in concatenation (.) or string at /etc/e-smith/templates-custom//etc/httpd/conf/httpd.conf/VirtualHosts/35Rewrite line 6.

The template expands, but when restart httpd and I display the site, I'm missing the formatting and icons, as if there is a permissions error (but it doesn't show in the logs). If I go back to the rule without the conditional logic, I see the home page as expected.

Do I need to escape the rule parameters?

Thanks,

Des
Des Dougan

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #4 on: February 04, 2005, 08:03:13 AM »
Charlie,

I've resolved the problem I reported last night - I changed from a Rewrite rule to ProxyPass and ProxyPassReverse directives, and when I put your code fragment around each directive, the template-expand worked fine, and my other domains now no longer display the primary domain content.

Very many thanks for your help.


Des
Des Dougan

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #5 on: March 31, 2005, 03:59:01 AM »
Des,

I used your rpms to install Plone. It worked really well. But I can't get at Plone itself.

I believe I need to put a ProxyPass and ProxyPassReverse directive into hhtpd.conf but I don't know enough about how the SME templates work to know what to do.

As I understand it, I need to create a config file fragment in Templates-Custom. But I need guidance with respect to (a) what name to use for the fragment and (b) what specifically goes in the file.

In my current case, I have a fresh install on a test machine and I am just trying to test against a local i-bay. However, in future I will want to do it on a production machine with the i-bay set to be a virtual host.

I'm something of a novice (just bought "Learning Perl") and not a programmer or Linux bright light. I would appreciate any direction you can give, the more specific the better. I'll learn.

Thanks for your help.

John
...

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #6 on: March 31, 2005, 06:56:41 AM »
John,

This is what works for me. Create the file 35Rewrite and paste the contents into it. The ProxyPass and ProxyPassReverse stuff should each be on one line, in case it doesn't display cleanly here.

Des

[root@jeeves root]# more /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts/35Rewrite
#
# ProxyPass directive for Zope/Plone Virtual Host Monster
#
ProxyPass / http://localhost:9080/VirtualHostBase/http/domainname.com:80/Plone/VirtualHostRoot/

ProxyPassReverse / http://localhost:9080/VirtualHostBase/http/domainname.com:80/Plone/VirtualHostRoot/
Des Dougan

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #7 on: March 31, 2005, 06:57:42 AM »
And, in case it's not clear, replace "domainname" with your own.

Des
Des Dougan

Offline wjhobbs

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

Thanks. I did that and still have a problem.

I have set up a virtual domain ('imsig.ca') against an i-bay ('imsig') which was the domain I specified in the ProxyPass directives. When I use a browser on another machine to access that i-bay (e.g., 192.168.1.253/imsig), I get the standard "This information bay has not yet been customized" message.

When I attempt to go directly at Plone by specifying the port number (e.g., 192.168.1.253:9080/Plone) I get 'connection refused'. I think this is because of the security you set up in the install so Zope/Plone accepts connections only from the local machine.

Without a browser on the SME machine, I don't know how to set up the Virtual Host Monster in Zope because of the 'connection refused' problem.

Any suggestions for what to try?

Thanks for your help.

John
...

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #9 on: April 02, 2005, 06:48:38 AM »
To access the ZMI, you need to set up an ssh tunnel to your server from your desktop (PuTTY is a good client on a Windows box) on port 9080, then connect to http://localhost:9080/manage to get to the ZMI, where you login with the plone IFD and password you set up when you installed Plone. You can then set up the VHM.


Des
Des Dougan

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #10 on: April 02, 2005, 06:40:17 PM »
Des,

A PuTTY connection just gives me CLI access. I can use Lynx; but the ZMI seems to need a frame-capable browser.

I have been unsuccessful getting a VPN tunnel connection established; but if I can, I suspect it will allow the browser access I need to get VHM set up.

Is there something I'm missing with PuTTY?

Am I on the right track?

Thanks for all the hand-holding.

John
...

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #11 on: April 02, 2005, 11:17:49 PM »
In PuTTY, you need to set up a tunnel. I'm running Linux on my desktop, so can't check, but from memory, near the bottom of the setup options, there is one for tunnels. Add 9080 and localhost:9080 in the dialog. This, when run, will allow you to access the ZMI via the browser. I think the help on the PuTTY download site discusses the options for tunnelling.

Des
Des Dougan

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #12 on: April 04, 2005, 01:51:09 AM »
Des,

Thanks for all your help.

I was not able to get the ssh tunnel working, either through PuTTY or ssh on a Linux desktop. The CLI worked but the tunnel didn't. I'll track that problem down another day.

Rather than spend the weekend tearing out what little hair I have left, I found a way around the problem. I adjusted zope.conf temporarily to allow remote connections. Then set up the Virtual Host Monster and reset the security on zope.conf.

Then applied your ProxyPass rules -- and everything worked just fine!

Thanks.

John
...

Offline ddougan

  • *
  • 155
  • +0/-0
    • http://www.DouganConsulting.com
Customizing httpd.conf with rewrite rules
« Reply #13 on: April 04, 2005, 04:38:57 AM »
Great! I'm glad you got it resolved.

For reference, from a Linux CLI, try:

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

where the IP address is that of the server's local internal interface.

Des
Des Dougan

Offline wjhobbs

  • *****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Customizing httpd.conf with rewrite rules
« Reply #14 on: April 09, 2005, 03:15:24 AM »
Des,

Thanks. Don't know where my mind was. I had localhost and local interface confused.

You may want to consider using the RewriteRule instead of ProxyPass. If you use Charlie's ... return nullstring unless ... construct and enclose the RewriteRule directive in single quotes, the expand-template function will not try to resolve the $1 variable in the directive.

John
...