положить в /etc/nginx/conf.d/
upstream app_server {# fail_timeout = 0 означает, что мы всегда пытаемся выполнить обратный поток, даже если он не смог # вернуть хороший HTTP-ответ
# for UNIX domain socket setups
fail_timeout = 0;
# for a TCP configuration
server <<gunicorn server ip and port>> fail_timeout=0;
}
сервер {# используйте 'listen 80 deferred;' для Linux # используйте 'listen 80 accept_filter = httpready;' для FreeBSD слушай 80; client_max_body_size 4G;
location = /favicon.ico { access_log off; log_not_found off; }
if ($http_x_forwarded_proto != 'https') {
return 301 https://$host$request_uri;
}
# set the correct host(s) for your site
server_name '<<server_url>>'
keepalive_timeout 5;
# path for static files
root /usr/share/nginx/html/sherlock;
location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
proxy_pass http://app_server;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /path/to/app/current/public;
}
error_log /var/log/nginx.log error;
}