nextcloud.conf 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #(可选)添加如下header主要为了安全
  2. add_header X-Content-Type-Options nosniff;
  3. add_header X-XSS-Protection "1; mode=block";
  4. add_header X-Robots-Tag none;
  5. add_header X-Download-Options noopen;
  6. add_header X-Permitted-Cross-Domain-Policies none;
  7. #(可选)为了支持user_webfinger app
  8. rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  9. rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  10. #这儿是为了支持日历和联系人,建议加上
  11. location = /.well-known/carddav {
  12. return 301 $scheme://$host/remote.php/dav;
  13. }
  14. location = /.well-known/caldav {
  15. return 301 $scheme://$host/remote.php/dav;
  16. }
  17. #设置上传文件的最大大小(还和php里的那个设置有关)
  18. client_max_body_size 512M;
  19. fastcgi_buffers 64 4K;
  20. #最主要的,将所有请求转发到index.php上
  21. location / {
  22. rewrite ^ /index.php$uri;
  23. }
  24. #安全设置,禁止访问部分敏感内容
  25. location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
  26. deny all;
  27. }
  28. location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
  29. deny all;
  30. }
  31. #这部分吧,默认就有,不过有所不同,所以我合并了下,替换原来的就行
  32. location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
  33. fastcgi_split_path_info ^(.+\.php)(/.*)$;
  34. fastcgi_param PATH_INFO $fastcgi_path_info;
  35. fastcgi_param modHeadersAvailable true;
  36. fastcgi_param front_controller_active true;
  37. fastcgi_pass unix:/dev/shm/php-cgi.sock;
  38. fastcgi_intercept_errors on;
  39. fastcgi_request_buffering off;
  40. include fastcgi.conf;
  41. }
  42. #安全设置,禁止访问部分敏感内容
  43. location ~ ^/(?:updater|ocs-provider)(?:$|/) {
  44. try_files $uri/ =404;
  45. index index.php;
  46. }
  47. location ~ \.(?:css|js|woff|svg|gif)$ {
  48. try_files $uri /index.php$uri$is_args$args;
  49. add_header Cache-Control "public, max-age=15778463";
  50. add_header X-Content-Type-Options nosniff;
  51. add_header X-XSS-Protection "1; mode=block";
  52. add_header X-Robots-Tag none;
  53. add_header X-Download-Options noopen;
  54. add_header X-Permitted-Cross-Domain-Policies none;
  55. access_log off;
  56. }
  57. location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
  58. try_files $uri /index.php$uri$is_args$args;
  59. access_log off;
  60. }
  61. location = /robots.txt {
  62. allow all;
  63. log_not_found off;
  64. access_log off;
  65. }
  66. gzip on;
  67. gzip_vary on;
  68. gzip_comp_level 4;
  69. gzip_min_length 256;
  70. gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  71. 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;