summaryrefslogtreecommitdiffstats
path: root/roles/nextcloud/files/etc/nginx/sites-available/nextcloud
blob: 52f24e0a56648861529b84c58a1957c78fa9f22c (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
server {
    listen      80;
    listen [::]:80;

    server_name cloud.fripost.org;

    include /etc/lacme/nginx.conf;

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

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

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

    server_name cloud.fripost.org;

    root /usr/local/share/nextcloud;

    include snippets/headers.conf;
    add_header X-Robots-Tag                      none;
    add_header X-Download-Options                noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

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

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

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

    location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; }
    location = /.well-known/caldav  { return 301 $scheme://$host/remote.php/dav; }

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;
    fastcgi_buffer_size 32k;

    # Enable gzip but do not remove ETag headers
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;

    location = / { return 303 $scheme://$host/apps/files/; }
    location   / { rewrite ^ /index.php$uri last; }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ { internal; }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)         { internal; }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|oc[ms]-provider/.+|core/templates/40[34])\.php(?:$|/) {
        include snippets/fastcgi-php.conf;
        fastcgi_param modHeadersAvailable     true;
        fastcgi_param front_controller_active true;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
        fastcgi_pass  unix:/run/php/php7.3-fpm@nextcloud.sock;
    }

    location ~ ^/(?:updater|oc[ms]-provider)(?:$|/) {
        try_files $uri/ =404;
        index index.php;
    }

    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        expires 30d;
        try_files $uri /index.php$uri$is_args$args;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /index.php$uri$is_args$args;
    }

    location = /core/img/favicon.ico {
        alias /var/www/nextcloud/fripost.ico;
    }
}

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

    server_name www.cloud.fripost.org;

    include /etc/lacme/nginx.conf;

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

    location / {
        return 301 https://cloud.fripost.org$request_uri;
    }
}