Welcome! Log In Create A New Profile

Advanced

Wonderful one-liners in configuration

April 30, 2009 01:19AM
I just love nginx, just adopted it today, and wanted to show my appreciation by sharing something I really like but haven't seen in any of the configuration examples: collapsing multiple-line config blocks into one line. For example here is my config for one of my sites. Look how nice and short it is :-)

[code]
upstream mongrel-hub { server 127.0.0.1:11000; server 127.0.0.1:11001; server 127.0.0.1:11002; }
server {
listen 80;
server_name xxx;
root /var/www/deployed-hub/current/public;
error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/nginx-default; }
if (-f $document_root/system/maintenance.html) { rewrite ^(.*)$ /system/maintenance.html last; break; }
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header -Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
if (-f $request_filename) { rewrite (.*) $1 break; }
if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; }
if (-f $request_filename.html) { rewrite (.*) $1.html break; }
if (!-f $request_filename) {
proxy_pass http://mongrel-hub;
break;
}
}
}
[/code]

I've compressed blocks that I'll never need to think about again (and stole from other rails sites anyway) and keep things nice and clear. Thanks!

http://simonwoodside.com
Subject Author Posted

Wonderful one-liners in configuration

sbwoodside April 30, 2009 01:19AM

Re: Wonderful one-liners in configuration

Igor Sysoev April 30, 2009 01:31AM

Re: Wonderful one-liners in configuration

sbwoodside May 15, 2009 10:27PM

Re: Wonderful one-liners in configuration

mike May 15, 2009 10:40PM

Re: Wonderful one-liners in configuration

Igor Sysoev May 16, 2009 12:42AM

Re: Wonderful one-liners in configuration

usen68 May 19, 2009 07:49AM

Re: Wonderful one-liners in configuration

nickychen August 13, 2010 08:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 213
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready