summaryrefslogtreecommitdiffstats
path: root/debian/nginx-example.conf
blob: 2b8766400e730bba7626242fa08be8c59a9d6625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
server {
        listen   443;
        server_name  *-welco.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/welco.example.org-access.log combined;
        error_log  /var/log/nginx/welco.example.org-error.log;

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

        location ~ ^/media/(.+)$ {
            alias /var/lib/welco/tenants/$host/media/$1;
        }

        location / {
            proxy_pass         http://unix:/var/run/welco/welco.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  *-welco.example.org;

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

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

        location ~ ^/media/(.+)$ {
            alias /var/lib/welco/tenants/$host/media/$1;
        }

        location / {
            proxy_pass         http://unix:/var/run/welco/welco.sock;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Real-IP       $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}