Document directory
- Applications
- Proxying with exceptions
My Apache 2.061 reports errors in window 2003. Although it can also be used, it is quite uncomfortable.
After a long time, there is no way to fix the sockt.
Error in the report queue: Incorrect application apache.exe, version 2.0.61.200, error module NTDLL. dll, version 5.2.20.0.3959, error location
I have been searching for a software to replace Apache. Recently I have read about Lighttpd and want to use Lighttpd to replace Apache. I will release the information first.
.
Http://ftp.dtech.hu/pub/WLMP-Project/LightTPD-Win32/
. When to use Lighttpd
You can use Lighttpd
- Secure access to your application server
- Reduce load on your server by offloading static requests
- Load Balance your application servers
- Use Lighttpd's spambot and bad bot blocking capabilities
- Get more request rewriting and redirecting flexibility
- Use the above flexibility to improve your search engine rankings
- Profit.
2. When not to use Lighttpd
You might not like Lighttpd if you
- Don't like grouping Software
- Use URLRewriting and
;jsessionid(Though a patch is available for this problem ).
3. Lighttpd modules you need
The following lighty modules are needed:
- Mod_access
- Mod_redirect
- Mod_rewrite
- Mod_proxy
Add them to yourserver.modulesSection:
server.modules = (
"mod_accesslog",
"mod_access",
"mod_redirect",
"mod_rewrite",
"mod_proxy",
"mod_status",
"mod_evhost",
"mod_expire"
)
4. Denying access to JeeDirectories
TheWEB-INFAndMETA-INFDirectories shouldn't be accessible through Lighttpd. files from your development environment also shouldn't be visible.
url.access-deny = ( "WEB-INF", ".classpath", ".project", "META-INF" )
5. Binding your application server to localhost
To prevent duplicate content penalties, your application server shouldn't be visible from the Web. Even if you run it on a high port, someone might eventually find it.
Binding a Web site to localhost looks like this in Orion's<name>-web-site.xml:
<web-site host="127.0.0.1" port="12345">
<frontend host="johannburkard.de" port="80"/>
Consult your documentation if you aren't using Orion.
6. Redirecting
www.To non-
www.Hosts
Even if you don't reallyNeedTo do this, I recommend doing so. Removing duplicate contentWillImprove your rankings.
The following snippet redirects all visitors fromwww.<domain>To<domain>With301Permanent redirect.
$HTTP["host"] =~ "^www\.(.*)___FCKpd___3quot; {
url.redirect = ( "^/(.*)" => "http://%1/$1" )
}
You shoshould also redirect all additional domains (johannburkard.com,johann-burkard.org) To your main domain.
7. proxying dynamic requests
We will usemod_proxyTo proxy some requests to your Java application server.
Depending on your site's structure, one of the following approaches will work better.
Simple JSP
If all you have is a bunch of Java Server Pages, the followingmod_proxyRule is sufficient:
proxy.server = ( ".jsp" =>
(
( "host" => "127.0.0.1",
"port" => "12345"
)
)
)
Note that the JSP Must be actual files. You cannot use servlets mapped to these URIS.
Applications
If you use servlets or more complex applications, You can proxy URIS by Prefix:
proxy.server = ( "/blog/" =>
(
( "host" => "127.0.0.1",
"port" => "12345"
)
)
)
Proxying with exceptions
If most of your site is dynamic and you have a directory for static content (/assets,/staticOr so), you can proxy all requestsExceptRequests for static files:
$HTTP["url"] !~ "^/static" {
proxy.server = ( "" =>
(
( "host" => "127.0.0.1",
"port" => "12345"
)
)
)
}
8. Rewriting requests
Lighttpd can dynamically rewrite requests. I mostly use this to usedefault.jspAs dynamic index file insteadindex.html. Here's an example:
url.rewrite-once = ( "^(.*)/___FCKpd___7quot; => "$1/default.jsp",
"^(.*)/([;?]+.*)___FCKpd___7quot; => "$1/default.jsp$2" )
This is visible at gra0.com and internally rewrites all requests from/To/default.jsp(IncludingjsessionidAnd query string ).
mod_rewriteCan also be used to make URLS shorter. For example, to remove?page=commentsQuery string, I use the following:
url.rewrite-once = (
"^/blog/(.*)\.html___FCKpd___8quot; => "/blog/$1.html?page=comments"
)
9. redirecting requests
You can usemod_redirectTo redirect the user to a different URL. Contrarymod_rewriteWhere the request is rewritten,301Permanent redirect will be sent to the browser.
In this example, I'm redirecting requests to an old domain to a new domain:
$HTTP["host"] == "olddomain.com" {
url.redirect = (
"^/(.*)___FCKpd___9quot; => "http://newdomain.com/$1"
)
}
10. More things to be aware
- The only IPAddress in your application server log files shocould be
127.0.0.1. If you need the original address, logX-FORWARDED-FORHeader.
- Don't analyze both Lighttpd and application server logs-lighty's log files already contain all requests.
- You might want to set up virtual hosts sooner or later.
- Use
mod_expireTo make resources cacheable. Doing so can make your site a lot faster and save you money.