summaryrefslogtreecommitdiffstats
path: root/roles/webmail/files/etc/nginx/sites-available/roundcube
blob: 05895ba4e550d0887d638a7b2fae5fcee6b72f6f (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
server {

    listen      80;
    listen [::]:80;

    server_name    mail.fripost.org;
    server_name webmail.fripost.org;

    include /etc/lacme/nginx.conf;

    access_log /var/log/nginx/roundcube.access.log;
    error_log  /var/log/nginx/roundcube.error.log info;

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


server {
    listen      443 ssl http2;
    listen [::]:443 ssl http2;

    server_name    mail.fripost.org;
    server_name webmail.fripost.org;

    root /var/lib/roundcube/public_html;

    include snippets/headers.conf;
    add_header Content-Security-Policy
               "default-src 'none'; frame-src 'self'; connect-src 'self'; object-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; frame-ancestors 'self'; form-action 'self'; base-uri mail.fripost.org webmail.fripost.org";

    include snippets/ssl.conf;
    ssl_certificate     ssl/mail.fripost.org.pem;
    ssl_certificate_key ssl/mail.fripost.org.key;
    include             snippets/mail.fripost.org.hpkp-hdr;

    gzip on;
    gzip_vary on;
    gzip_min_length 256;
    gzip_types application/font-woff application/font-woff2 application/javascript application/json application/xml image/svg+xml image/x-icon text/css text/plain text/vcard;

    location = /favicon.ico {
        root          /usr/share/roundcube/skins/default/images;
        log_not_found off;
        access_log    off;
    }

    location = /robots.txt {
        allow         all;
        log_not_found off;
        access_log    off;
    }

    access_log /var/log/nginx/roundcube.access.log;
    error_log  /var/log/nginx/roundcube.error.log info;

    client_max_body_size 64m;
    location = / { index index.php; }
    location = /index.php {
        # TODO enable gzip for Roundcube >=1.5: it's immune to BREACH attacks once
        # $config['session_samesite'] is set to 'Strict', see
        #   https://github.com/roundcube/roundcubemail/pull/6772
        #   https://www.sjoerdlangkemper.nl/2016/11/07/current-state-of-breach-attack/#same-site-cookies
        gzip off;
        include snippets/fastcgi-php-ssl.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm@roundcube.sock;
    }

    location ~ "^/(?:plugins|program/js|program/resources|skins)(?:/[[:alnum:]][[:alnum:]\-\._]*)+\.(?:css|eot|gif|html|ico|jpg|js|pdf|png|svg|tiff?|ttf|webp|woff2?)$" {
        expires 30d;
        try_files $uri =404;
    }
    location / { internal; }
}