Aug 162010
 

You can setup a custom error page for every location block in your nginx.conf, or a global error page for the site as a whole.

To redirect to a simple 404 not found page for a specific location:

location /my_blog {
    error_page    404 = /article_not_found.html;
}

A site wide 404 page:

server {
listen 80;
    error_page  404  /page_not_found.html;
    ...

You can append standard error codes together to have a single page for several types of errors:

location /my_blog {
 error_page 500 502 503 504 = /server_error.html
}

To redirect to a totally different server, assuming you had an upstream server named server2 defined in your http section:

upstream server2 {
    server 10.0.0.1:80;
}
server {
    location /my_blog {
        error_page    404 = @try_server2;
    }
    location @try_server2 {
        proxy_pass http://server2;
    }

The manual can give you more details, or you can search google for the terns nginx.conf and error_page for real life examples on the web.

Oct 042009
 

A “hello world” program has become the traditional first program that many people learn. Here’s i’ll show you how to print “Hello World” in A web page.

Using HTML

<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
   <HEAD>
      <TITLE>
         Hello World
      </TITLE>
   </HEAD>
<BODY>
   <P>hello world</P>
</BODY>
</HTML>

Continue reading »