]> git.sesse.net Git - pr0n/blob - doc/README
Fix an (irrelevant) confusion about addEventListener.
[pr0n] / doc / README
1 pr0n is copyright Steinar H. Gunderson <sgunderson@bigfoot.com>. Everything
2 (that includes the Perl code, the configuration snippets, the database schema,
3 the CSS, the templates, any HTML or JavaScript and any documentation, but _not_
4 any of the images on pr0n.sesse.net etc.) is licensed under the GNU General
5 Public License, version 2. For the full license text, see the COPYING file.
6
7 Documentation? Forget it; if you can't set it up, use something else. You can
8 have a typical Varnish snippet, though:
9
10 backend pr0n {
11     .host = "127.0.0.1";
12     .port = "5015";
13 }
14
15 sub vcl_recv {
16     if (req.http.host ~ "^pr0n\.sesse\.net(:[0-9]+)?$") {
17         set req.backend_hint = pr0n;
18         if (req.http.accept ~ "(^|,)image/avif($|,|;)") {
19             set req.http.accept = "image/avif,*/*";
20         } else {
21             set req.http.accept = "*/*";
22         }
23         if (req.method == "PUT") {
24             return (pipe);
25         }
26     }
27 }
28
29 sub vcl_deliver {
30     if (resp.http.x-varnish-host && resp.http.x-pr0n-purge) {
31         set resp.http.escaped-regex = regsuball(resp.http.x-pr0n-purge, "\\", "\\\\");
32         ban ( "obj.http.x-varnish-host == " + resp.http.x-varnish-host + " && obj.http.x-varnish-url ~ " + resp.http.escaped-regex );
33         unset resp.http.escaped-regex;
34     }
35     unset resp.http.x-varnish-host;
36     unset resp.http.x-varnish-url;
37     unset resp.http.x-pr0n-purge;
38 }
39
40 sub vcl_backend_response {
41     if (bereq.http.host ~ "^pr0n\.sesse\.net(:[0-9]+)?$") {
42         set beresp.ttl = 1w;
43         set beresp.http.x-varnish-host = bereq.http.host;
44         set beresp.http.x-varnish-url = bereq.url;
45         if (beresp.http.content-type ~ "^(text/html|text/plain|text/xml|text/css|application/x-javascript|application/javascript)") {
46             set beresp.do_gzip = true;
47         }
48     } else {
49         unset beresp.http.x-varnish-host;
50     }
51 }
52
53 To redeploy after changes:
54
55   sudo service pr0n reload && sudo varnishadm 'ban obj.http.x-varnish-host ~ "."'
56