Advertisement
Nebelherr

Nextcloud - nginx vHost

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