Denisle

nextcloud nginx config

May 24th, 2022 (edited)
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 4.13 KB | None | 0 0
  1. upstream php-handler {
  2. server unix:/run/php/php8.1-fpm.sock;
  3. }
  4.     map $arg_v $asset_immutable {
  5.     "" "";
  6.     default "immutable";
  7.     }
  8.  
  9. server {
  10.     listen 80;
  11.     listen [::]:80;
  12.     server_name nc.domain.ru;
  13.  
  14.     server_tokens off;
  15.  
  16.     client_max_body_size 10G;
  17.         client_body_timeout 3600s;
  18.         fastcgi_buffers 64 4K;
  19.         gzip on;
  20.         gzip_vary on;
  21.         gzip_comp_level 4;
  22.         gzip_min_length 256;
  23.         gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  24.         gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.m>
  25.         add_header Strict-Transport-Security            "max-age=15768000; includeSubDomains; preload;" always;
  26.         add_header Permissions-Policy                   "interest-cohort=()";
  27.         add_header Referrer-Policy                      "no-referrer"   always;
  28.         add_header X-Content-Type-Options               "nosniff"       always;
  29.         add_header X-Download-Options                   "noopen"        always;
  30.         add_header X-Frame-Options                      "SAMEORIGIN"    always;
  31.         add_header X-Permitted-Cross-Domain-Policies    "none"          always;
  32.         add_header X-Robots-Tag                         "none"          always;
  33.         add_header X-XSS-Protection                     "1; mode=block" always;
  34.         fastcgi_hide_header X-Powered-By;
  35.  
  36.         root /var/www/nextcloud;
  37.  
  38.     index index.php index.html /index.php$request_uri;
  39.  
  40.     location = / {
  41.         if ( $http_user_agent ~ ^DavClnt ) {
  42.             return 302 /remote.php/webdav/$is_args$args;
  43.         }
  44.     }
  45.  
  46.     location = /robots.txt {
  47.         allow all;
  48.         log_not_found off;
  49.         access_log off;
  50.     }
  51.  
  52.     location ^~ /apps/rainloop/app/data {
  53.         deny all;
  54.     }
  55.  
  56.     location ^~ /.well-known {
  57.     return 301 /index.php$request_uri;
  58.     }
  59.  
  60.     location = /.well-known/carddav { return 301 /remote.php/dav/; }
  61.     location = /.well-known/caldav  { return 301 /remote.php/dav/; }
  62. #    location = /.well-known/webfinger   { return 301 /index.php$uri; }
  63. #    location = /.well-known/nodeinfo   { return 301 /index.php$uri; }
  64.     location /.well-known/pki-validation { try_files $uri $uri/ =404; }
  65.    
  66.     location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)  { return 404; }
  67.  
  68.     location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)                { return 404; }
  69.  
  70.     location ~ \.php(?:$|/) {
  71.         rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;
  72.         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  73.         set $path_info $fastcgi_path_info;
  74.         try_files $fastcgi_script_name =404;
  75.         include fastcgi_params;
  76.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  77.         fastcgi_param PATH_INFO $path_info;
  78.         fastcgi_param HTTPS on;
  79.         fastcgi_param modHeadersAvailable true;
  80.         fastcgi_param front_controller_active true;
  81.         fastcgi_pass php-handler;
  82.         fastcgi_intercept_errors on;
  83.         fastcgi_request_buffering off;
  84.         fastcgi_read_timeout 3600;
  85.         fastcgi_send_timeout 3600;
  86.         fastcgi_connect_timeout 3600;
  87.         fastcgi_max_temp_file_size 0;
  88.     }
  89.  
  90.         location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
  91.                 try_files $uri /index.php$request_uri;
  92.                 add_header Cache-Control "public, max-age=15778463, $asset_immutable";
  93.                 expires 6M;
  94.                 access_log off;
  95.  
  96.         location ~ \.wasm$ {
  97.                 default_type application/wasm;
  98.         }
  99.         }
  100.  
  101.         location ~ \.woff2?$ {
  102.                 try_files $uri /index.php$request_uri;
  103.                 expires 7d;
  104.                 access_log off;
  105.         }
  106.  
  107.         location /remote {
  108.                 return 301 /remote.php$request_uri;
  109.         }
  110.  
  111.         location / {
  112.                 try_files $uri $uri/ /index.php$request_uri;
  113.         }
  114.  
  115. }
Add Comment
Please, Sign In to add comment