nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Drupal/lua rules for lighttpd

This is a discussion on Drupal/lua rules for lighttpd within the Web servers forums, part of the Mastering Servers category; Hi .. can someone with expertise in lighty rules please help..I am using Drupal CMS on a LLMP stack and ...


Go Back   nixCraft Linux Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 25-08-2008, 02:09 AM
Junior Member
User
 
Join Date: Aug 2008
OS: CentOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jtrudeau is on a distinguished road
Default Drupal/lua rules for lighttpd

Hi .. can someone with expertise in lighty rules please help..I am using Drupal CMS on a LLMP stack and I am stuck on trying

to come up with rules for a particular module I am wanting to use.


In lighttpd.conf I have:
========================
$HTTP["host"] =~ "(^|\.)mydomain\.com" {
server.document-root = "/var/www/public_html/mydomain.com/"
index-file.names = ( "index.php" )
# for clean urls
magnet.attract-physical-path-to = ("/etc/lighttpd/rewrite_drupal.lua")
}

In rewrite_drupal.lua I have:
==============================
-- little helper function
function file_exists(path)
local attr = lighty.stat(path)
if (attr) then
return true
else
return false
end
end
function removePrefix(str, prefix)
return str:sub(1,#prefix+1) == prefix.."/" and str:sub(#prefix+2)
end

-- prefix without the trailing slash

-- If reverting back to production mode comment in the above line and uncomment the line below

local prefix = ''

-- the magic
if (not file_exists(lighty.env["physical.path"])) then
-- file still missing. pass it to the fastcgi backend
request_uri = removePrefix(lighty.env["uri.path"], prefix)
if request_uri then
lighty.env["uri.path"] = prefix .. "/index.php"
local uriquery = lighty.env["uri.query"] or ""
lighty.env["uri.query"] = uriquery .. (uriquery ~= "" and "&" or "") .. "q=" .. request_uri
lighty.env["physical.rel-path"] = lighty.env["uri.path"]
lighty.env["request.orig-uri"] = lighty.env["request.uri"]
lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
end
end
-- fallthrough will put it back into the lighty request loop
-- that means we get the 304 handling for free.

----------------------------------------------------------------------------------

Given the above here is my question :

I want to know how to enable the following rules for a drupal module called "boost" which tries
to serve cached html pages bypassing php/drupal and the database. There is a write-up on this
at: Boost your Drupal site! | Code Sorcery Workshop

Now for this Drupal module to work, there are rewrite rules needed. Currently the module author
has noly provided htaccess rules for Apache. I need lighttpd rules. I have pasted above the rules
I currently have in lighttpd.conf and rewrite_drupal.lua file. Can someone pls help me with the rules to
add to the lua or the lighttpd.conf file to make this module work.

I am pasting below the htaccess rules specific to this module that the author is recommending. If anyone
has any suggestions on how it can work with lighttpd that would be a big help.

# Apache htaccess Rewrite rules for static page caching provided by the Boost module:
# BOOST START
<IfModule mod_headers.c>
Header add Expires "Sun, 19 Nov 1978 05:00:00 GMT"
Header add Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
</IfModule>
<IfModule mod_mime.c>
AddCharset utf-8 .html
</IfModule>
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/index.html -f
RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/index.html [L]
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} !^/cache
RewriteCond %{REQUEST_URI} !^/user/login
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI} -d
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}/index.html -f
RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1/index.html [L]
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} !^/cache
RewriteCond %{REQUEST_URI} !^/user/login
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1.html [L]
# BOOST END

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
Reply With Quote
  #2 (permalink)  
Old 25-08-2008, 08:31 PM
raj's Avatar
raj raj is offline
Senior Member
User
 
Join Date: Jun 2005
Location: Hyderabad
OS: Fedora, Debian Linux
Posts: 307
Thanks: 42
Thanked 8 Times in 8 Posts
Rep Power: 6
raj will become famous soon enough raj will become famous soon enough
Default

Well I'm not lighttpd expert, most of the htaccess stuff won't work on Lighttpd as conditional stuff is not avilable under lighttpd such as
%{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^$
__________________
Raj
Linux rulz.
I have never turned back in my life ; I shall not do so today.. haha
Reply With Quote
  #3 (permalink)  
Old 02-09-2008, 06:27 AM
Junior Member
User
 
Join Date: Aug 2008
OS: CentOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jtrudeau is on a distinguished road
Default

not unless you factor in mod_magnet and then the corresponding scripting in lua to handle the conditionals.
Reply With Quote
  #4 (permalink)  
Old 07-09-2008, 12:20 AM
Junior Member
User
 
Join Date: Aug 2008
OS: CentOS
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jtrudeau is on a distinguished road
Default Finally figured it out

Figured it out . Check my(drupdrips)s)s) post at

Lighttpd rewrite rules wanted | drupal.org

I 'd appreciate any suggestions on improving it for functionality and performance.

Last edited by jtrudeau; 07-09-2008 at 12:21 AM. Reason: typo
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
how to make iptable rules? saroj Networking, Firewalls and Security 7 11-03-2009 06:18 PM
Lighttpd Gallery2 URL Rewrite (.htaccess) SEO Rules rootadmin Web servers 2 22-06-2008 06:57 PM
iptables rules blocking ftp hammooda Linux software 7 23-09-2006 04:24 PM
iptables rules for three ethernet brijeshchougule Linux software 2 16-06-2005 02:42 PM
Forum rules vivek Feedback & Site News 0 01-02-2005 11:04 AM


All times are GMT +5.5. The time now is 10:14 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38