You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
6.6 KiB

3 years ago
  1. worker_processes auto;
  2. error_log /var/log/nginx/error.log warn;
  3. pid /var/run/nginx.pid;
  4. events {
  5. worker_connections 1024;
  6. }
  7. http {
  8. include /etc/nginx/mime.types;
  9. default_type application/octet-stream;
  10. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  11. '$status $body_bytes_sent "$http_referer" '
  12. '"$http_user_agent" "$http_x_forwarded_for"';
  13. access_log /var/log/nginx/access.log main;
  14. sendfile on;
  15. #tcp_nopush on;
  16. keepalive_timeout 65;
  17. set_real_ip_from 10.0.0.0/8;
  18. set_real_ip_from 172.16.0.0/12;
  19. set_real_ip_from 192.168.0.0/16;
  20. real_ip_header X-Real-IP;
  21. #gzip on;
  22. upstream php-handler {
  23. server nextcloud:9000;
  24. }
  25. server {
  26. listen 80;
  27. # Add headers to serve security related headers
  28. # Before enabling Strict-Transport-Security headers please read into this
  29. # topic first.
  30. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
  31. #
  32. # WARNING: Only add the preload option once you read about
  33. # the consequences in https://hstspreload.org/. This option
  34. # will add the domain to a hardcoded list that is shipped
  35. # in all major browsers and getting removed from this list
  36. # could take several months.
  37. add_header Referrer-Policy "no-referrer" always;
  38. add_header X-Content-Type-Options "nosniff" always;
  39. add_header X-Download-Options "noopen" always;
  40. add_header X-Frame-Options "SAMEORIGIN" always;
  41. add_header X-Permitted-Cross-Domain-Policies "none" always;
  42. add_header X-Robots-Tag "none" always;
  43. add_header X-XSS-Protection "1; mode=block" always;
  44. # Remove X-Powered-By, which is an information leak
  45. fastcgi_hide_header X-Powered-By;
  46. # Path to the root of your installation
  47. root /var/www/html;
  48. location = /robots.txt {
  49. allow all;
  50. log_not_found off;
  51. access_log off;
  52. }
  53. # The following 2 rules are only needed for the user_webfinger app.
  54. # Uncomment it if you're planning to use this app.
  55. #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  56. #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  57. # The following rule is only needed for the Social app.
  58. # Uncomment it if you're planning to use this app.
  59. #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
  60. location = /.well-known/carddav {
  61. return 301 $scheme://$host:$server_port/remote.php/dav;
  62. }
  63. location = /.well-known/caldav {
  64. return 301 $scheme://$host:$server_port/remote.php/dav;
  65. }
  66. # set max upload size
  67. client_max_body_size 10G;
  68. fastcgi_buffers 64 4K;
  69. # Enable gzip but do not remove ETag headers
  70. gzip on;
  71. gzip_vary on;
  72. gzip_comp_level 4;
  73. gzip_min_length 256;
  74. gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  75. 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;
  76. # Uncomment if your server is build with the ngx_pagespeed module
  77. # This module is currently not supported.
  78. #pagespeed off;
  79. location / {
  80. rewrite ^ /index.php;
  81. }
  82. location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
  83. deny all;
  84. }
  85. location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
  86. deny all;
  87. }
  88. location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
  89. fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
  90. set $path_info $fastcgi_path_info;
  91. try_files $fastcgi_script_name =404;
  92. include fastcgi_params;
  93. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  94. fastcgi_param PATH_INFO $path_info;
  95. # fastcgi_param HTTPS on;
  96. # Avoid sending the security headers twice
  97. fastcgi_param modHeadersAvailable true;
  98. # Enable pretty urls
  99. fastcgi_param front_controller_active true;
  100. fastcgi_pass php-handler;
  101. fastcgi_intercept_errors on;
  102. fastcgi_request_buffering off;
  103. }
  104. location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
  105. try_files $uri/ =404;
  106. index index.php;
  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;" always;
  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 Referrer-Policy "no-referrer" always;
  125. add_header X-Content-Type-Options "nosniff" always;
  126. add_header X-Download-Options "noopen" always;
  127. add_header X-Frame-Options "SAMEORIGIN" always;
  128. add_header X-Permitted-Cross-Domain-Policies "none" always;
  129. add_header X-Robots-Tag "none" always;
  130. add_header X-XSS-Protection "1; mode=block" always;
  131. # Optional: Don't log access to assets
  132. access_log off;
  133. }
  134. location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
  135. try_files $uri /index.php$request_uri;
  136. # Optional: Don't log access to other assets
  137. access_log off;
  138. }
  139. }
  140. }