2

I've started the migration of a Windows VPS to linode.com, choosing lighttpd over nginx and apache to host some sites built on asp.net mvc, and I'm stuck with what I think is a "document-root" conflict.

I'm running lighttpd 1.4.6, Mono 2.8.2 on Ubuntu 10.04

I've configured mod_evhost with the patterns to match this directory structure:

/var/webs/country-tld.tld.domain/www
/var/webs/country-tld.tld.domain/subdomain

and to remove all "www" from the requests, redirecting to the url, and everything works fine for static content, but when loading aspx pages I constantly get 404 errors for default.aspx.

When I set server.document-root to any website (bypassing the evhost rules) Mono worked fine, serving the aspx pages as expected. Which pointed me to think that, when evhost is enabled, "MONO_FCGI_ROOT" = server.document-root is gets mixed the rest of the configuration causing the 404 for aspx content.

Does anyone have experience with this environment set up? I really want to give lighttpd's configuration elegance and simplicity a chance before setting everything with Apache+mod_mono, or use individual fastcgi mappings for every host.

These are my configuration files.

/etc/lighttpd/lighttpd.conf:

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_accesslog",
    "mod_compress",
    "mod_rewrite",
    "mod_redirect",
    "mod_evhost"
)

server.document-root = "/var/webs/default/"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"

index-file.names = (
    "index.html",
    "index.htm",
    "default.htm",
    "default.html"
)

accesslog.filename = "/var/log/lighttpd/access.log"

url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

server.port = 80
server.pid-file = "/var/run/lighttpd.pid"
server.dir-listing = "enable"
server.username = "www-data"
server.groupname = "www-data"
#server.error-handler-404  = "/error-handler.html"

dir-listing.encoding = "utf-8"

compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = (
    "text/plain", 
    "text/html", 
    "application/x-javascript", 
    "text/css"
)
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

### for global domains with 3 or more letters in last .ext
### and for national domains but -no- second level
$HTTP["host"] =~ "^(www.)?([^.]+)\.([a-z]{2,})$" {
  evhost.path-pattern = "/var/webs/%1.%2/www/"
}
$HTTP["host"] =~ "^(www.)?([^.]+)\.([^.]+)\.([a-z]{2,})$" {
  evhost.path-pattern = "/var/webs/%1.%2/%3/"
}
### for second level national domains with 2 letters in last .ext
###  %4       %3      %2    %1
### sub   domain  subtld   tld
$HTTP["host"] =~ "^(www.)?([^.]+)\.([a-z]{2,3})\.([a-z]{2})$" {
  evhost.path-pattern = "/var/webs/%1.%2.%3/www/"
}
$HTTP["host"] =~ "^(www.)?([^.]+)\.([^.]+)\.([a-z]{2,3})\.([a-z]{2})$" {
  evhost.path-pattern = "/var/webs/%1.%2.%3/%4/"
}

# redirect "www.domain" to "domain" preserving the parameters
$HTTP["host"] =~ "^www\.(.*)$" {
  url.redirect = ( "^/(.*)" => "http://%1/$1" )
}


#### handle Debian Policy Manual, Section 11.5. urls
## by default allow them only from localhost
## (This must come last due to #445459)
## Note: =~ "127.0.0.1" works with ipv6 enabled, whereas == "127.0.0.1" doesn't
$HTTP["remoteip"] =~ "127.0.0.1" {
    alias.url += (
        "/doc/" => "/usr/share/doc/",
        "/images/" => "/usr/share/images/"
    )
    $HTTP["url"] =~ "^/doc/|^/images/" {
        dir-listing.activate = "enable"
    }
}

/etc/lighttpd/conf-enabled/10-fastcgi.conf:

index-file.names += (
    "index.aspx",
    "default.aspx",
    "Index.aspx",
    "Default.aspx"
)

var.mono_dir = "/opt/mono-2.8.2/"
var.mono_shared_dir = "/tmp/"
var.mono_fastcgi_server = mono_dir + "bin/" + "fastcgi-mono-server2"
var.mono_fcgi_root = server.document-root
var.mono_fcgi_applications = "/:."

server.modules   += ( "mod_fastcgi" )

fastcgi.server = (
        ".aspx" => ((
                "socket" => mono_shared_dir + "fastcgi-mono-server",
                "bin-path" => mono_fastcgi_server,
                "bin-environment" => (
                        "PATH" => "/bin:/usr/bin:" + mono_dir + "bin",
                        "LD_LIBRARY_PATH" => mono_dir + "lib:",
                        "MONO_SHARED_DIR" => mono_shared_dir,
                        "MONO_FCGI_LOGLEVELS" => "Standard",
                        "MONO_FCGI_LOGFILE" => mono_shared_dir + "fastcgi.log",
                        "MONO_FCGI_ROOT" => mono_fcgi_root,
                        "MONO_FCGI_APPLICATIONS" => mono_fcgi_applications
                ),
                "max-procs" => 1,
                "check-local" => "disable"
        ))
)

fastcgi.map-extensions = (
        ".asmx"   => ".aspx",
        ".ashx"   => ".aspx",
        ".asax"   => ".aspx",
        ".ascx"   => ".aspx",
        ".soap"   => ".aspx",
        ".rem"    => ".aspx",
        ".axd"    => ".aspx",
        ".cs"     => ".aspx",
        ".config" => ".aspx",
        ".dll"    => ".aspx"
)

0

You must log in to answer this question.

Browse other questions tagged .