I tried several times and on multiple occasions to try and fix the below code for nginx with unicorn, but it just isen't working. So now posting here in last report some of you more talented could see my mistake and others can benefit from it too.
Im using:
- nginx
- unicorn
The problem is
- No 502 error shown ( I use cap deploy:web:disable task to write the maintenance.html )
- If nginx is running but unicorn is not im also getting a 502 error page
The nginx config:
upstream unicorn {
server unix:/srv/books/shared/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80 deferred;
server_name books.*;
client_max_body_size 4G;
keepalive_timeout 10;
server_tokens off;
root /srv/books/public;
location / {
try_files /system/maintenance.html $uri/index.html $uri @unicorn;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
error_page 502 /system/maintenance.html;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
}