FVN Tech Blog Coding or Programming in C#/PHP | Linux or Windows Server Backend | New Media | SNS | Misc …

11Oct/080

mod_extforward for lighttpd 1.5 r2994

Lighttpd team roll out a prerelease of 1.5 r2294, get it here(http://blog.lighttpd.net/articles/2008/08/20/new-prereleases-1-4-20-r2294-and-1-5-r2294). I modified mod_extforward to make it work with it (some constants changed since last prerelease).

orz to the author of mod_extforward, great kxn.

see att for patch.

lighttpd-150-r2294-mod_extforward

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
18Jun/070

lighttpd 1.5.0 pr on Debian sid step by step

Download:

http://www.lighttpd.net/download/lighttpd-1.5.0-r1857.tar.gz

Prerequisites:

sudo aptitude install libglib2.0-dev libpcre3-dev zlib1g-dev libaio-dev libbz2-dev automake1.9

Configure:

./configure –prefix={yourprefix}

Build:

make clean install

Run:

{yourprefix}/sbin/lighttpd –f {yourprefix}/etc/lighttpd.conf

More:

I modified mod_extforward to make it compatible with 1.5.0 pre-release

Patch:

cd your-path-to-source/lighttpd-1.5.0/
patch -p1 < lighttpd-1.5.0-pr-mod_extforward.patch
autoreconf

patch:
lighttpd-1.5.0-pr-mod_extforward.patch

Trac on lighttpd

$HTTP["host"] =~ "^trac\.lighttpd\.net" {
    # alias, ...

    $HTTP["url"] =~ "^/trac/" {
        proxy-core.backends = ( "127.0.0.1:9090" )
        proxy-core.protocol = "fastcgi"
        proxy-core.rewrite-request = (
           "_pathinfo" => ( "^/trac(/.*)" => "$1" ),
           "_scriptname" => ( "^(/trac/)" => "$1" )
        )
    }
}

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
20Apr/071

Lighttpd url-redirect for Wordpress Permlink changes

I changed my wordpress blog entry permlink format. But some link to my blog exists on Internet doesn't work which results in a HTTP 404 error.

Why redirect is better then rewrite

Someone may have the same question, but take it easy, it depends on your decision.

But rewrite has it's benefits also, existed link will work without any changes. RSS feed, your live writer(maybe you prefer Word2007? :P) will still work, no need to change the configuration.

I want all visitors include search engine spiders get to know that the permlink changes, that's why I choose redirect, not rewrite.

Draft conf, simple and ugly

For example, http://feuvan.net/wordpress/?p=107 now should be http://blog.feuvan.net/index.php/2007/03/10/win-ce-platform-builder-60-evalutation-offline-download.html, then I have to configure my lighttpd configure like these.

$HTTP["url"] =~ "^/wordpress" {
    url.redirect =(
        "^/wordpress/(.*)$" => "http://blog.feuvan.net/index.php/$1"
    )
}

But some links like http://feuvan.net/wordpress/index.php?p=56 will be redirected to http://blog.feuvan.net/index.php/index.php?p=56, it's ugly, er......

More clean conf file

So here we have a newer configure file:

$HTTP["url"] =~ "^/wordpress" {
    url.redirect =(
        "^/wordpress/index.php?(.*)$" => "http://blog.feuvan.net/index.php/$1",
        "^/wordpress/(.*)$" => "http://blog.feuvan.net/index.php/$1"
    )
}

Now the old link will be redirected to http://blog.feuvan.net/index.php/?p=56.

Furthermore

Wait, why not redirect to the new permlink directly?

Maybe I can throw out a solution.

NOTE:

You should enable mod_redirect to make the configuration works for you.

The article is specified to lighttpd 1.4.x series.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
17Apr/072

Configure nginx as front-end web server

I've been using lighttpd for a long time, it's faster and stable. But 1.4.x series of lighttpd lacks some features I need: powerful proxy mod, dav_svn mod, real IP extract (as mod_extract_forwarded in apache).

Most of the bandwidth of feuvan.net is contributed to a web game proxy using proxy mod of lighttpd 1.4.13 : http://chaoswar.feuvan.net (official: http://alpha.chaoswar.cn:8080 ),  the lighttpd causes many TIME_WAIT connections in high load condition. Therefore, I want to use a powerful proxy like squid to do the proxy work. nginx ( Engine X ) is my selection. Squid is too heavy ;-).

It's easy to install in debian, just type aptitude install nginx as root. Then I changed lighttpd listening port to localhost:81, and configure nginx to run on 0.0.0.0:80.

nginx.conf:

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  4096;
    use epoll;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  35;
    tcp_nodelay        on;

    gzip  on;

    server {
        listen       80;

        location / {
            proxy_pass http://127.0.0.1:81;
            include         /etc/nginx/proxy.conf;
        }

    }

    upstream chaoswar_cn {
        server alpha.chaoswar.cn:8080;
    }
    server {
        listen          80;
        server_name     chaoswar.feuvan.net;

        location / {
            proxy_pass http://chaoswar_cn;
            include         /etc/nginx/proxy.conf;
        }
    }
}

proxy.conf:

proxy_redirect          off;
proxy_set_header        Host $host;
proxy_set_header        X-Real-IP $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   30;
proxy_send_timeout      30;
proxy_read_timeout      30;
proxy_buffer_size       4k;
proxy_buffers           4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

The most content of configure files are copied from nginx wiki, it's easy to read. And may be I can do more optimizations like static content (picuture) cache ( expire 30d?). But the main purpose of this article is to show you a general whole picture of the proxy function of Nginx.

BTW, nginx is not just a light-weight squid like proxy server! It's also a HTTP/MAIL Server.

Anyway, I'm still waiting for 1.5.0 release of lighttpd.

See also: nginx, nginx wiki, lighttpd 1.4.x mod_proxy, lighttpd 1.5.x mod_proxy_core

Nginx vs Lighttpd for a small VPS

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged as: , 2 Comments

Pages

Recent Posts

Categories

Tags

apache baidu C# Debian dotNET economy gadget GMA Google hulu IE7 Intel jiwai lighttpd Linux Mobile mod_extforward mojiti nginx oscanner OVAL Parallel PHP phproxy politics proxy Python regsvr32 SNS squid subversion trac TV Vista Visual Studio Windows Live Windows Mobile WLM wordpress wow WTL wzdftpd XDebug XML Zend Framework

Archives

Meta

友情链接与广告

Free web proxy
Old friends:

NSClub: