Guest User

Untitled

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