Created
February 26, 2010 06:37
-
-
Save jordanbrock/315481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www www; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/spool/nginx/nginx.pid; | |
events { | |
worker_connections 1024; | |
use /dev/poll; # important on Solaris | |
} | |
http { | |
include /opt/local/etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] $request ' | |
'"$status" $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile off; # important on Solaris | |
keepalive_timeout 60; | |
server_tokens off; | |
gzip on; | |
gzip_http_version 1.0; | |
gzip_comp_level 2; | |
gzip_proxied any; | |
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
#include the website configuration file | |
include /opt/local/etc/nginx/virtualhosts/website.conf; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream unicorn_server { | |
server unix:/home/website/web/apps/website/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
# Redirect domains with www to their no-www counterpart. | |
#################################### | |
# DOMAIN REDIRECTS | |
#################################### | |
server { | |
listen 80; | |
server_name website.com; | |
rewrite ^ http://www.website.com$request_uri?; | |
} | |
#################################### | |
# SERVER CONFIG | |
#################################### | |
server { | |
listen 80; | |
server_name www.website.com website.com; | |
client_body_buffer_size 128k; | |
client_max_body_size 50M; | |
root /home/website/web/apps/website/current/public; | |
keepalive_timeout 5; | |
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; | |
location / { | |
#try_files /system/maintenance.html $uri $uri/index.html $uri.html @app_server; | |
if (!-f $request_filename){ | |
#pass all the requests onto the unicorn_server | |
proxy_pass http://unicorn_server; | |
break; | |
} | |
} | |
error_page 500 502 503 504 /500.html; | |
location = /500.html { | |
root /home/website/web/apps/website/current/public; | |
} | |
} | |
server { | |
listen 443; | |
# Defaults to hostname | |
server_name www.website.com; | |
ssl on; | |
ssl_certificate /home/website/etc/2008/www.website.com.crt; | |
ssl_certificate_key /home/website/etc/2008/www.website.com.key; | |
#ssl_prefer_server_ciphers on; | |
keepalive_timeout 70; | |
root /var/empty; | |
location / { | |
proxy_redirect off; | |
proxy_pass http://www.website.com; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-FORWARDED-PROTO https; | |
} | |
error_page 500 502 503 504 /500.html; | |
location = /500.html { | |
root /home/website/web/apps/website/current/public; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment