Skip to content

Instantly share code, notes, and snippets.

@damm
Created October 7, 2009 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damm/204384 to your computer and use it in GitHub Desktop.
Save damm/204384 to your computer and use it in GitHub Desktop.
## http://brainspl.at/nginx.conf.txt
#user and group to run as
user nginx nginx;
# number of nginx workers
worker_processes 4;
# pid of nginx master process
# pid /var/run/nginx.pid
error_log /var/log/nginx/error_log info;
events {
worker_connections 8192;
use epoll;
}
# start the http module where we config http access.
http {
# pull in mime-types. You can break out your config
# into as many include's as you want to make it cleaner
include /etc/nginx/mime.types;
# set a default type for the rare situation that
# nothing matches from the mimie-type include
default_type application/octet-stream;
# configure log format
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#log_format main ‘$remote_addr - $remote_user [$time_local] “$request” ‘
#‘$status $body_bytes_sent “$http_referer” ‘
#‘”$http_user_agent” “$http_x_forwarded_for”‘;
# main access log
access_log /var/log/nginx/access.log main;
# main error log
error_log /var/log/nginx/error.log debug;
#error_log logs/error.log debug_http;
# no sendfile on OSX
sendfile on;
# These are good default values.
tcp_nopush on;
tcp_nodelay off;
# output compression saves bandwidth
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml
application/xml+rss text/javascript;
# this is where you define your mongrel clusters.
# you need one of these blocks for each cluster
# and each one needs its own name to refer to it later.
# the server directive is nginx's virtual host directive.
server {
# port to listen on. Can also be set to an IP:PORT
listen 74.94.68.193:80;
# sets the domain[s] that this vhost server requests for
server_name blog.livid.dk;
# rewrite ^/xml/atom/feed.xml /articles.rss;
# doc root
root /root/feather/public/files;
# vhost specific access log
access_log /var/log/nginx/blog.livid.dk-access_log main;
#Set the max size for file uploads to 50Mb
client_max_body_size 50M;
# this rewrites all the requests to the maintenance.html
# page if it exists in the doc root. This is for capistrano's
# disable web task
if (-f $document_root/maintenance.html){
rewrite ^(.*)$ /maintenance.html last;
break;
}
#if ($host ~* "www") {
# rewrite ^(.*)$ http://blog.livid.dk$1 permanent;
# break;
#}
location /status {
stub_status on;
access_log off;
allow 127.0.0.1;
allow 10.1.10.0/24;
allow 74.94.68.193/32;
deny all;
}
location /files {
fancyindex on;
fancyindex_exact_size off;
root /home/nginx/feather/public;
}
location /stylesheets {
root /home/nginx/feather/public;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
}
location /javascript {
root /home/nginx/feather/public;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
}
location /images {
root /home/nginx/feather/public;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_max_temp_file_size 0;
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://127.0.0.1:4485;
break;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment