Category Archives: http

Permanent redirect with nginx

server { server_name domain.com; rewrite ^(.*)$ http://www.domain.com$1 permanent; }

Nginx and worker_connections are more than open file resource limit warning

If you encounter this warning message under Linux: 2009/03/09 21:23:19 [warn] 26827#0: 4096 worker_connections are more than open file resource limit: 1024 A solution is to use the command ulimit in nginx start script, just before lunching nginx: [...] ulimit  -n 65536 [...]

Amazon is moving into CDN market

As read in Diamond Notes, Amazon is moving into CDN market with CloudFront. Some Content Delivery Network providers Akamaï Akamaï on Crunchbase BitGravity BitGravity on Crunchbase EdgeCast Networks EdgeCast Networks on Crunchbase Limelight Network Limelight Network on Crunchbase Panther Express Panther Express on Crunchbase

Fix nginx increase server_names_hash_bucket_size error

When adding new virtual hosts in your nginx configuration file, you can experience this error message: # nginx -t 2008/11/13 09:37:03 [emerg] 12299#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32 2008/11/13 09:37:03 [emerg] 12299#0: the configuration file /etc/nginx/nginx.conf test failed server_names_hash_bucket_size controls the maximum length of a virtual host entry (ie the [...]

Maintenance mode (HTTP 503) with lighttpd and PHP

When you put your website in maintenance mode, it’s a good idea to return a HTTP 503 error code to the client. This code indicates that “the server is currently unable to handle the request due to a temporary overloading or maintenance of the server”. The 503 code is used to avoid crawlers or caching [...]

Permanent redirect (301) with lighttpd

If you want to redirect visitors that access your website without the ‘www’, you can use mod_redirect with the following syntax: $HTTP[”host”] =~ “^lescampeurs\.org” { url.redirect = ( ”^/(.*)$” => “http://www.lescampeurs.org/$1″ ) } Links: Lighttpd mod_redirect HTTP 3xx status codes

Rotate Apache logs with Cronolog

Cronolog is log rotation program which gives you a lot of options to template the log destination files. The common use is to split logs by year / month / day. Here is how to configure Apache to send log entries to cronolog : CustomLog “|/usr/sbin/cronolog /home/log/apache2/%Y-%m-%d_domain.com_access.log” combined This will create a log file named [...]

Deny access to .svn directories with Apache2 / lighttpd

If you’re using SVN to control your web application, your certainly need to deny access to .svn sub-directories. With Apache2 <DirectoryMatch “^/.*/\.svn/”> Order allow,deny Deny from all </DirectoryMatch> With lighttpd $HTTP["url"] =~ “/\.svn/” { url.access-deny = ( “” ) }

WordPress replaces pound by nginx

After two years of using Pound, WordPress decided to switch to Nginx as software load balancers for WordPress.com. Read the full story on Barry’s Blog.

Use mod_redirect with lighttpd

Enable mod_redirect server.modules += ( “mod_redirect” ) Force your domain with www. $HTTP["host"] =~ “^domain\.com$” { url.redirect = ( “^/(.*)” => “http://www.domain.com/$1″ ) } Force your domain without www. $HTTP["host"] =~ “^www\.domain\.com$” { url.redirect = ( “^/(.*)” => “http://domain.com/$1″ ) } Redirect HTTP requests to HTTPS $SERVER["socket"] == “:80″ { $HTTP["host"] =~ “(.*)” { url.redirect [...]