upstream example {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/webapps/example.com/gunicorn.sock fail_timeout=0;
}
server{
listen 80;
server_name example.com;
client_max_body_size 4G;
access_log /webapps/example.com/logs/nginx-access.log;
error_log /webapps/example.com/logs/nginx-error.log;
# Robot.txt configuration
# developers work on robot.txt more so it is suitable to push inside source code.
location /robots.txt {
alias /webaps/example.org/robots.txt;
}
# Static assets configuration
location /static/ {
alias /webapps/example.com/master/src/assets/;
expires 30d;
}
# Media configuration
location /media/ {
alias /webapps/example.com/master/src/media/;
expires 30d;
}
# Need to review
location / {
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://example; #app name
break;
}
}
# Favicon configuration
location /favicon.ico {
alias /webapps/example.com/master/src/assets/img/favicon.ico;
}
# Prevent hidden files being serverd
location ~ /\. { access_log off; log_not_found off; deny all; }
# Error page configuration
error_page 500 502 503 504 /500.html;
location = /500.html {
root /webapps/example.com/master/src/static/;
}
}