upstream app_server { server 127.0.0.1:8000 fail_timeout=10 max_fails=3 ; server app02:8000 fail_timeout=10 max_fails=3 down; } server { server_name newsblur.com; rewrite ^(.*) http://www.newsblur.com$1 permanent; } server { listen 80; listen 443 default_server ssl; ssl on; ssl_certificate /home/sclay/newsblur/config/certificates/newsblur.com.crt; ssl_certificate_key /home/sclay/newsblur/config/certificates/newsblur.com.key; client_max_body_size 4M; server_name www.newsblur.com push.newsblur.com 199.15.250.228 127.0.0.1; # if ($host = 'newsblur.com') { # rewrite ^/(.*)$ https://www.newsblur.com/$1 permanent; # } error_page 503 @maintenance; location @maintenance { rewrite ^(.*)$ /home/sclay/newsblur/media/maintenance.html break; } location /media/ { expires max; keepalive_timeout 1; root /home/sclay/newsblur; } location /static/ { expires max; keepalive_timeout 1; root /home/sclay/newsblur; } location /favicon.ico { alias /home/sclay/newsblur/media/img/favicon.png; expires max; access_log off; } location ^~ /crossdomain.xml { expires max; alias /home/sclay/newsblur/media/crossdomain.xml; types { text/x-cross-domain-policy xml; } } location ^~ /robots.txt { expires max; alias /home/sclay/newsblur/media/robots.txt; } location /munin/ { alias /var/cache/munin/www/; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; allow 199.15.250.228; deny all; } location / { if (-f /home/sclay/newsblur/media/maintenance.html) { return 503; } proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://app_server; break; } } }