Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

156 рядки
5.8KB

  1. {{ ansible_managed | comment }}
  2. upstream php-handler {
  3. server unix:/var/run/php/php{{nextcloud_php_version}}-fpm.sock;
  4. }
  5. server {
  6. listen 80;
  7. listen [::]:80;
  8. server_name {{nextcloud_server_names|join(' ')}};
  9. location /.well-known/acme-challenge {
  10. default_type "text/plain";
  11. root /var/www/default;
  12. }
  13. # enforce https
  14. return 301 https://$server_name:443$request_uri;
  15. }
  16. server {
  17. listen 443 ssl http2;
  18. listen [::]:443 ssl http2;
  19. server_name {{nextcloud_server_names|join(' ')}};
  20. ssl_certificate /etc/ssl/certs/{{nextcloud_server_names|first}}.fullchain.pem;
  21. ssl_certificate_key /etc/ssl/private/{{nextcloud_server_names|first}}.key.pem;
  22. # Add headers to serve security related headers
  23. # Before enabling Strict-Transport-Security headers please read into this
  24. # topic first.
  25. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
  26. #
  27. # WARNING: Only add the preload option once you read about
  28. # the consequences in https://hstspreload.org/. This option
  29. # will add the domain to a hardcoded list that is shipped
  30. # in all major browsers and getting removed from this list
  31. # could take several months.
  32. add_header X-Content-Type-Options nosniff;
  33. add_header X-XSS-Protection "1; mode=block";
  34. add_header X-Robots-Tag none;
  35. add_header X-Download-Options noopen;
  36. add_header X-Permitted-Cross-Domain-Policies none;
  37. add_header Referrer-Policy no-referrer;
  38. # Remove X-Powered-By, which is an information leak
  39. fastcgi_hide_header X-Powered-By;
  40. # Path to the root of your installation
  41. root /var/www/nextcloud;
  42. location = /robots.txt {
  43. allow all;
  44. log_not_found off;
  45. access_log off;
  46. }
  47. # The following 2 rules are only needed for the user_webfinger app.
  48. # Uncomment it if you're planning to use this app.
  49. #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  50. #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  51. # The following rule is only needed for the Social app.
  52. # Uncomment it if you're planning to use this app.
  53. #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
  54. location = /.well-known/carddav {
  55. return 301 $scheme://$host:$server_port/remote.php/dav;
  56. }
  57. location = /.well-known/caldav {
  58. return 301 $scheme://$host:$server_port/remote.php/dav;
  59. }
  60. # set max upload size
  61. client_max_body_size 512M;
  62. fastcgi_buffers 64 4K;
  63. # Enable gzip but do not remove ETag headers
  64. gzip on;
  65. gzip_vary on;
  66. gzip_comp_level 4;
  67. gzip_min_length 256;
  68. gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  69. 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;
  70. # Uncomment if your server is build with the ngx_pagespeed module
  71. # This module is currently not supported.
  72. #pagespeed off;
  73. location / {
  74. rewrite ^ /index.php;
  75. }
  76. location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
  77. deny all;
  78. }
  79. location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
  80. deny all;
  81. }
  82. location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
  83. fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
  84. set $path_info $fastcgi_path_info;
  85. try_files $fastcgi_script_name =404;
  86. include fastcgi_params;
  87. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  88. fastcgi_param PATH_INFO $path_info;
  89. fastcgi_param HTTPS on;
  90. # Avoid sending the security headers twice
  91. fastcgi_param modHeadersAvailable true;
  92. # Enable pretty urls
  93. fastcgi_param front_controller_active true;
  94. fastcgi_pass php-handler;
  95. fastcgi_intercept_errors on;
  96. fastcgi_request_buffering off;
  97. }
  98. location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
  99. try_files $uri/ =404;
  100. index index.php;
  101. }
  102. # Adding the cache control header for js, css and map files
  103. # Make sure it is BELOW the PHP block
  104. location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
  105. try_files $uri /index.php$request_uri;
  106. add_header Cache-Control "public, max-age=15778463";
  107. # Add headers to serve security related headers (It is intended to
  108. # have those duplicated to the ones above)
  109. # Before enabling Strict-Transport-Security headers please read into
  110. # this topic first.
  111. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
  112. #
  113. # WARNING: Only add the preload option once you read about
  114. # the consequences in https://hstspreload.org/. This option
  115. # will add the domain to a hardcoded list that is shipped
  116. # in all major browsers and getting removed from this list
  117. # could take several months.
  118. add_header X-Content-Type-Options nosniff;
  119. add_header X-XSS-Protection "1; mode=block";
  120. add_header X-Robots-Tag none;
  121. add_header X-Download-Options noopen;
  122. add_header X-Permitted-Cross-Domain-Policies none;
  123. add_header Referrer-Policy no-referrer;
  124. # Optional: Don't log access to assets
  125. access_log off;
  126. }
  127. location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
  128. try_files $uri /index.php$request_uri;
  129. # Optional: Don't log access to other assets
  130. access_log off;
  131. }
  132. }