aboutsummaryrefslogtreecommitdiffstats
path: root/roles/nginx/templates/nodes.site.j2
blob: df6c369d03c0d6c4bf214dc5ac5559ecb0a71c1d (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
#
# /etc/nginx/sites-available/nodes.site
# Nginx site:
# * APT mirror proxy for LAN nodes
# * Serve extra files and configurations to nodes
#

server {
    listen  80;
    listen  [::]:80;

    access_log  /var/log/nginx/nodes.access.log;
    error_log   /var/log/nginx/nodes.error.log;

    allow  {{ lan_network }};
    deny   all;

    root   /srv/www;
    index  index.html index.htm;

    location /nodes {
         # Allow directory listing output
        autoindex             on;
        # Round file sizes kB, MB, GB
        autoindex_exact_size  off;
        # Show times in local time zone
        autoindex_localtime   on;
    }

    location /debian/ {
        try_files  $uri @mirror;
    }
    location /debian-security/ {
        try_files  $uri @mirror;
    }

    location @mirror {
        proxy_pass           http://{{ apt_mirror }};
        proxy_next_upstream  error timeout http_404;
        proxy_set_header     Host            {{ apt_mirror }};
        proxy_set_header     X-Real-IP       $remote_addr;
        proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;

        add_header  X-Mirror-Upstream-Status        $upstream_status;
        add_header  X-Mirror-Upstream-Response-Time $upstream_response_time;
        add_header  X-Mirror-Status                 $upstream_cache_status;
    }
}