summaryrefslogtreecommitdiff
path: root/nginx/server.conf
blob: 68ebf9fb0edb802189849913ab1c62390bc2da95 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
server {
    listen 80;
    listen [::]:80;
    server_name www.grapheneos.org grapheneos.org;

    root /var/empty;

    return 301 https://grapheneos.org$request_uri;
}

server {
    include /etc/nginx/snippets/https.conf;
    server_name www.grapheneos.org;

    root /var/empty;

    include /etc/nginx/snippets/security-headers.conf;

    return 301 https://grapheneos.org$request_uri;
}

server {
    include /etc/nginx/snippets/https.conf;
    server_name grapheneos.org;

    root /var/www/html;
    error_page 403 =404 /404.html;
    error_page 404 /404.html;

    charset utf-8;
    include /etc/nginx/snippets/security-headers.conf;
    gzip_static on;

    if ($request_uri ~ ^/(.*)\.html$) {
        return 301 /$1;
    }

    if ($request_uri ~ ^(.*)/index$) {
        return 301 $1/;
    }

    location = /security.txt {
        return 301 /.well-known/security.txt;
    }

    location = /graphene.png {
        return 301 /logo.png;
    }

    location = /pdfviewer_privacy_policy {
        return 301 /pdfviewer-privacy-policy;
    }

    location = /safari_pinned_tab_icon.svg {
        return 301 /mask-icon.svg;
    }

    location = /safari-pinned-tab-icon.svg {
        return 301 /mask-icon.svg;
    }

    location = /bitcoin_address.png {
        return 301 /bitcoin-address.png;
    }

    # mangled backlinks to /install
    location = /installMinimal {
        return 301 /install;
    }

    location = /LICENSE {
        default_type text/plain;
    }

    location = /404 {
        internal;
        http2_push /grapheneos.css?18;
    }

    location = /404.html {
        internal;
        http2_push /grapheneos.css?18;
    }

    location ~ "\.(ico|webmanifest)$" {
        include /etc/nginx/snippets/security-headers.conf;
        add_header Cache-Control "public, max-age=604800";
    }

    location ~ "\.(css|js|svg)$" {
        include /etc/nginx/snippets/security-headers.conf;
        add_header Cache-Control "public, max-age=31536000";
    }

    location ~ "\.(png|woff2)$" {
        include /etc/nginx/snippets/security-headers.conf;
        add_header Cache-Control "public, max-age=31536000";
        gzip_static off;
    }

    location ~ "\.(txt|xml)$" {
        include /etc/nginx/snippets/security-headers.conf;
        add_header Cache-Control "public, max-age=1800";
    }

    # https://www.twipu.com/GrapheneOS doesn't handle links with fragments properly
    location ~ "^/(.*)<a href=$" {
        return 301 https://grapheneos.org/$1;
    }

    location ~ "\.(br|gz)" {
        internal;
    }

    location / {
        include /etc/nginx/snippets/security-headers.conf;
        add_header Cache-Control "public, max-age=1800";
        try_files $uri $uri.html $uri/ =404;
        http2_push /grapheneos.css?18;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name connectivitycheck.grapheneos.org;

    root /var/empty;

    location = /generate_204 {
        return 204;
    }

    location / {
        return 301 https://connectivitycheck.grapheneos.org$request_uri;
    }
}

server {
    include /etc/nginx/snippets/https.conf;
    server_name connectivitycheck.grapheneos.org;

    root /var/empty;

    include /etc/nginx/snippets/security-headers.conf;

    location = /generate_204 {
        return 204;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name mta-sts.grapheneos.org mta-sts.mail.grapheneos.org;

    root /var/empty;

    return 301 https://mta-sts.grapheneos.org$request_uri;
}

server {
    include /etc/nginx/snippets/https.conf;
    server_name mta-sts.grapheneos.org mta-sts.mail.grapheneos.org;

    root /var/www/mta-sts;

    include /etc/nginx/snippets/security-headers.conf;
}