# Shelfzilla Vhost
server {
    listen 443 ssl;
    server_name shelfzilla.com www.shelfzilla.com;
    ssl_certificate         ./ssl/shelfzilla.pem;
    ssl_certificate_key     ./ssl/shelfzilla.key;
    client_max_body_size 10M;
    client_body_temp_path /tmp/;
    server_tokens off;

    if ($host = 'www.shelfzilla.com') {
        return 301 $scheme://shelfzilla.com;
    }

    location /static/ {
        alias {{ static_root }};
        expires 1d;
    }

    location /media/ {
        alias {{ media_root }};
        expires 1d;
    }

    location /files/ {
        alias {{ media_root }}/filer/public/;
        expires 31d;
    }

    location /files/thumbnails/ {
        alias {{ media_root }}/filer/public/thumbnails/;
        expires 31d;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /landing {
                return 301 $scheme://$server_name;
        }

}

server {
    listen 443 ssl;
    server_name media.shelfzilla.com;
    ssl_certificate         ./ssl/shelfzilla.pem;
    ssl_certificate_key     ./ssl/shelfzilla.key;

    location / {
        alias {{ media_root }};
        expires 1d;
    }

    location /files/ {
        alias {{ media_root }}/filer/public/;
        expires 31d;
    }
}

server {
    listen 443 ssl;
    server_name static.shelfzilla.com;
    ssl_certificate         ./ssl/shelfzilla.pem;
    ssl_certificate_key     ./ssl/shelfzilla.key;

    location / {
        add_header 'Access-Control-Allow-Origin' "https://shelfzilla.com";
        alias {{ static_root }}/;
        expires 1d;
    }
}