how cache lighttpd with fastcgi rails?

22 views
Skip to first unread message

Chandle.WEi

unread,
Aug 18, 2009, 10:58:12 PM8/18/09
to mod_cache
rails use lighttpd fastcgi socket methods.
and I would use mod cache
but how to set proxy.server my lighttpd version is 1.4.23
I scan http://www.linux.com.cn/modcache/
It show me below
proxy.server = ( "/" =>
(
( "host" => "x.x.x.x", "port" => 80 ) # real backend
http server ip and port
)
)
Really?Wether I need to build another http server for this proxy?

shellcode

unread,
Aug 19, 2009, 12:01:31 AM8/19/09
to mod_...@googlegroups.com
you can use 'svn checkout http://lighttpd-improved.googlecode.com/svn/trunk/ lighttpd-improved-read-only' to checkout newest source

mod_fastcgi is patched to work with mod_cache

ChandleWEi

unread,
Aug 19, 2009, 12:51:30 AM8/19/09
to mod_...@googlegroups.com
在 2009-08-19三的 12:01 +0800,shellcode写道:
> http://lighttpd-improved.googlecode.com/
Thx but how to config it I find it look up cache.bases directory but
not wirte it

I set cache.support-queries , cache.bases, cache.refresh-pattern three
params

shellcode

unread,
Aug 19, 2009, 1:44:14 AM8/19/09
to mod_...@googlegroups.com
mod_fastcgi output contains http headers which tell modcache don't cache, such as 'Set-Cookie:', 'Accept-Encoding', 'Vary:' and so on

ChandleWEi

unread,
Aug 19, 2009, 2:25:28 AM8/19/09
to mod_...@googlegroups.com
server.port = 3001
cache.support-queries = "enable"
cache.debug = "enable"
cache.bases = ("/opt/cache")
cache.refresh-pattern = (
"\.(?i)(flv)$" => "0 fetchall-for-range-request flv-streaming",
# to w>>ork with mod_flv_streaming for flv files

"\.(?i)(js|css|xml)$" => "240", # update js/css/xml every 4 hours and
>>on refresh requests
"\.(?i)(htm|html|shtml)$" => "30", # update html/htm/shtml every
30 mi>>nutes and on refresh requests
"\.(?i)(jpg|bmp|jpeg|gif|png)$" => "2880", # update graphics
files eve>>ry 2 days
"\.(?i)(rar|zip|wmv|avi|mp3|ape|rm|mpeg|mpg|wma|asf|rmvb|flv)$"
=> "0 >>fetchall-for-range-request", # cache media file forever
"." => "30 update-on-refresh" # default to update every 30
minutes and>> on refresh requests
)
##mod_proxy setting, config your backend servers here
proxy.server = ( ".jpg" =>
(
( "host" => "192.168.1.242", "port" => 3001 ) # real backend
http server ip and port
)
)
##it's important to enable proxy.worked-with-mod-cache or mod_proxy will
not cooperate with modcache
proxy.worked-with-mod-cache = "enable"

$HTTP["host"] == "192.168.1.242" {
server.document-root = "/var/rails_work/v2/public"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (".fcgi" =>
("localhost" =>
("min-procs" => 1,
"max-procs" => 4,
"socket" => "/tmp/lighttpd/socket/rails.socket",
"bin-path" =>
"/var/rails_work/v2/public/dispatch.fcgi",
"bin-environment" => ("RAILS_ENV" => "production")
)
)
)
}-


I just want I can cache my static picture file , How to setup
lighttpd.conf?

在 2009-08-19三的 13:44 +0800,shellcode写道:

ChandleWEi

unread,
Aug 19, 2009, 2:33:24 AM8/19/09
to mod_...@googlegroups.com
============================below is strace lighttpd.pid=========
ioctl(6981, FIONREAD, [53036]) = 0
read(6981, "GET /1.jpg HTTP/1.0\r\nHost: 192.1"..., 53055) = 53036
brk(0x1b148000) = 0x1b148000
write(3, "2009-08-19 14:29:31: (mod_cache."..., 79) = 79
stat64("/opt/cache/192.168.1.242:3001/1.jpg", 0xbf92d0ac) = -1 ENOENT
(No such file or directory)
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 6982
fcntl64(6982, F_SETFD, FD_CLOEXEC) = 0
fcntl64(6982, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(6982, {sa_family=AF_INET, sin_port=htons(3001),
sin_addr=inet_addr("192.168.1.242")}, 16) = -1 EINPROGRESS (Operation
now in progress)
epoll_ctl(6, EPOLL_CTL_ADD, 6982, {EPOLLOUT|EPOLLERR|EPOLLHUP,
{u32=6982, u64=6982}}) = 0
setsockopt(6982, SOL_SOCKET, SO_DEBUG, NULL, 0) = -1 EINVAL (Invalid
argument)
epoll_ctl(6, EPOLL_CTL_DEL, 6981, {0, {u32=0, u64=0}}) = 0
time(NULL) = 1250663371
=======================================================
It looks can find cache file but can't write file to cache

I think that is my lighttpd proxy error but I don't know how to set it
在 2009-08-19三的 13:44 +0800,shellcode写道:

ChandleWEi

unread,
Aug 19, 2009, 3:06:40 AM8/19/09
to mod_...@googlegroups.com
Your means is mod_fastcgi can't use modcache?
在 2009-08-19三的 13:44 +0800,shellcode写道:

shellcode

unread,
Aug 19, 2009, 3:28:03 AM8/19/09
to mod_...@googlegroups.com
make sure that load mod_cache before mod_fastcgi

ChandleWEi

unread,
Aug 19, 2009, 3:39:52 AM8/19/09
to mod_...@googlegroups.com
Yes mod_cache before mod_fastcgi .

在 2009-08-19三的 15:28 +0800,shellcode写道:

ChandleWEi

unread,
Aug 19, 2009, 3:52:39 AM8/19/09
to mod_...@googlegroups.com
It seems I can't proxy lighttpd self , it will move in circle
在 2009-08-19三的 15:28 +0800,shellcode写道:
Reply all
Reply to author
Forward
0 new messages