jupiterbjy

nginx nextcloud

May 17th, 2020
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.88 KB | None | 0 0
  1. upstream php-handler {
  2. server 127.0.0.1:9000;
  3. server unix:/var/run/php/php7.4-fpm.sock;
  4. }
  5.  
  6. server {
  7. listen 127.0.0.1:5141;
  8.  
  9.  
  10. keepalive_timeout 70;
  11.  
  12. # SECURITY
  13. add_header Referrer-Policy "no-referrer" always;
  14. add_header X-Content-Type-Options "nosniff" always;
  15. add_header X-Download-Options "noopen" always;
  16. add_header X-Frame-Options "SAMEORIGIN" always;
  17. add_header X-Permitted-Cross-Domain-Policies "none" always;
  18. add_header X-Robots-Tag "none" always;
  19. add_header X-XSS-Protection "1; mode=block" always;
  20. fastcgi_hide_header X-Powered-By;
  21.  
  22. root /var/www/nextcloud;
  23.  
  24. location = /robots.txt {
  25. allow all;
  26. log_not_found off;
  27. access_log off;
  28. }
  29.  
  30. # The following 2 rules are only needed for the user_webfinger app.
  31. # Uncomment it if you're planning to use this app.
  32. #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  33. #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  34.  
  35. # The following rule is only needed for the Social app.
  36. # Uncomment it if you're planning to use this app.
  37. #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
  38.  
  39. location = /.well-known/carddav {
  40. return 301 https://MY_DOMAIN/nextcloud/remote.php/dav;
  41.  
  42. # return 301 $scheme://$host:$server_port/remote.php/dav;
  43. # return 301 $scheme://127.0.0.1/remote.php/dav;
  44. }
  45. location = /.well-known/caldav {
  46. return 301 https://MY_DOMAIN/nextcloud/remote.php/dav;
  47.  
  48. # return 301 $scheme://$host:$server_port/remote.php/dav;
  49. # return 301 $scheme://127.0.0.1/remote.php/dav;
  50. }
  51.  
  52. # set max upload size
  53. client_max_body_size 16G;
  54. fastcgi_buffers 64 4K;
  55.  
  56. # Enable gzip but do not remove ETag headers
  57. gzip on;
  58. gzip_vary on;
  59. gzip_comp_level 4;
  60. gzip_min_length 256;
  61. gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  62. gzip_types application/atom+xml application/javascript application/json application/ld+json applicat
  63. ion/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application
  64. /x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype imag
  65. e/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.locatio
  66. n.xloc text/vtt text/x-component text/x-cross-domain-policy;
  67.  
  68. # Uncomment if your server is build with the ngx_pagespeed module
  69. # This module is currently not supported.
  70. #pagespeed off;
  71.  
  72. location / {
  73. rewrite ^ /index.php;
  74. }
  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.  
  83. location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-pr
  84. ovider\/.+)\.php(?:$|\/) {
  85. fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
  86. set $path_info $fastcgi_path_info;
  87. try_files $fastcgi_script_name =404;
  88. include fastcgi_params;
  89. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  90. fastcgi_param PATH_INFO $path_info;
  91. fastcgi_param HTTPS on;
  92. # Avoid sending the security headers twice
  93. fastcgi_param modHeadersAvailable true;
  94. # Enable pretty urls
  95. fastcgi_param front_controller_active true;
  96. fastcgi_pass php-handler;
  97. fastcgi_intercept_errors on;
  98. fastcgi_request_buffering off;
  99. }
  100.  
  101. location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
  102. try_files $uri/ =404;
  103. index index.php;
  104. }
  105.  
  106. # Adding the cache control header for js, css and map files
  107. # Make sure it is BELOW the PHP block
  108. location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
  109. try_files $uri /index.php$request_uri;
  110. add_header Cache-Control "public, max-age=15778463";
  111. # Add headers to serve security related headers (It is intended to
  112. # have those duplicated to the ones above)
  113. # Before enabling Strict-Transport-Security headers please read into
  114. # this topic first.
  115. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
  116. #
  117. # WARNING: Only add the preload option once you read about
  118. # the consequences in https://hstspreload.org/. This option
  119. # will add the domain to a hardcoded list that is shipped
  120. # in all major browsers and getting removed from this list
  121. # could take several months.
  122. add_header Referrer-Policy "no-referrer" always;
  123. add_header X-Content-Type-Options "nosniff" always;
  124. add_header X-Download-Options "noopen" always;
  125. add_header X-Frame-Options "SAMEORIGIN" always;
  126. add_header X-Permitted-Cross-Domain-Policies "none" always;
  127. add_header X-Robots-Tag "none" always;
  128. add_header X-XSS-Protection "1; mode=block" always;
  129.  
  130. # Optional: Don't log access to assets
  131. access_log off;
  132. }
  133.  
  134. location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
  135. try_files $uri /index.php$request_uri;
  136. # Optional: Don't log access to other assets
  137. access_log off;
  138. }
  139. }
Add Comment
Please, Sign In to add comment