Advertisement
Guest User

Untitled

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