Skip to content

Instantly share code, notes, and snippets.

@gumayunov
Created September 14, 2009 20:44
Show Gist options
  • Save gumayunov/186917 to your computer and use it in GitHub Desktop.
Save gumayunov/186917 to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name *.domain.com;
root /www/domain.com;
access_log /var/log/nginx/domain.com.access.log urchin;
location ~* ^/.+(\.gif|\.png|\.jpg|\.css|\.js|\.swf|\.ico)$ {
expires 2d;
}
location /administrator {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Request-Filename $request_filename;
proxy_pass http://127.0.0.1:9001;
}
location / {
default_type text/html;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Request-Filename $request_filename;
if (-f $request_filename) {
proxy_pass http://127.0.0.1:9001;
break;
}
if (-f $request_filename/index.php) {
proxy_pass http://127.0.0.1:9001;
break;
}
if ($request_method = POST ) {
rewrite ^/([^.]+)$ /index.php/$1 break;
proxy_pass http://127.0.0.1:9001;
break;
}
if ($query_string != '') {
rewrite ^/([^.]+)$ /index.php/$1 break;
proxy_pass http://127.0.0.1:9001;
break;
}
set $memcached_key "domain.com:$uri";
memcached_pass 127.0.0.1:11211;
proxy_intercept_errors on;
error_page 404 502 = @fallback;
}
location @fallback {
internal;
set $origuri "$uri";
rewrite ^/([^.]+)$ /index.php/$1 break;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Request-Filename $request_filename;
proxy_set_header Memcached "set";
proxy_set_header Orig-URI $origuri;
proxy_pass http://127.0.0.1:9001;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment