nginx.conf for danbooru+passenger/mongrel

In this I assumed that passenger’s nginx is running on another server/instances/port. It’s a waste of memory, but my current setup forced me to do this.

upstream passenger {
server {
        listen 80;
        root /var/www/rails/danbooru/public;
        client_max_body_size 30m;
        location /(data|javascripts|stylesheets) {
                expires max;
        location /maintenance.html {
                expires 10;
        location / {
                try_files /maintenance.html $uri @genboard;
        location @genboard {
          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_pass http://passenger;
        error_page 404 /404.html;
        error_page 500 502 503 504 /500.html;

Basically it simplifies the setting using 0.7’s try_files and regex-in-location method. Also usable if you happen to use mongrel(_cluster).

Leave a Reply

Your email address will not be published. Required fields are marked *