Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

154 rindas
5.9KB

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