server {
        listen   443;
        server_name  *.passerelle.example.org;

        ssl                  on;
        ssl_certificate      /etc/ssl/certs/ssl-cert-snakeoil.pem;
        ssl_certificate_key  /etc/ssl/private/ssl-cert-snakeoil.key;

        access_log  /var/log/nginx/passerelle.example.org-access.log combined;
        error_log  /var/log/nginx/passerelle.example.org-error.log;

        location ~ ^/static/(.+)$ {
            root /;
            try_files /var/lib/passerelle/tenants/$host/static/$1
                      /var/lib/passerelle/collectstatic/$1
                      =404;
        }

        location / {
            proxy_pass         http://unix:/run/passerelle/passerelle.sock;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Forwarded-SSL on;
            proxy_set_header   X-Forwarded-Protocol ssl;
            proxy_set_header   X-Forwarded-Proto https;
            proxy_set_header   X-Real-IP       $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

server {
        listen   80;
        server_name  *.passerelle.example.org;

        access_log  /var/log/nginx/passerelle.example.org-access.log combined;
        error_log  /var/log/nginx/passerelle.example.org-error.log;

        return 301 https://$host$request_uri;
}

