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.

156 lines
5.8 KiB

  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. #gzip on;
  18. upstream php-handler {
  19. server app:9000;
  20. }
  21. server {
  22. listen 80;
  23. # Add headers to serve security related headers
  24. # Before enabling Strict-Transport-Security headers please read into this
  25. # topic first.
  26. # add_header Strict-Transport-Security "max-age=15768000;
  27. # includeSubDomains; preload;";
  28. #
  29. # WARNING: Only add the preload option once you read about
  30. # the consequences in https://hstspreload.org/. This option
  31. # will add the domain to a hardcoded list that is shipped
  32. # in all major browsers and getting removed from this list
  33. # could take several months.
  34. add_header X-Content-Type-Options nosniff;
  35. add_header X-XSS-Protection "1; mode=block";
  36. add_header X-Robots-Tag none;
  37. add_header X-Download-Options noopen;
  38. add_header X-Permitted-Cross-Domain-Policies none;
  39. add_header Referrer-Policy no-referrer;
  40. root /var/www/html;
  41. location = /robots.txt {
  42. allow all;
  43. log_not_found off;
  44. access_log off;
  45. }
  46. # The following 2 rules are only needed for the user_webfinger app.
  47. # Uncomment it if you're planning to use this app.
  48. #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  49. #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
  50. # last;
  51. location = /.well-known/carddav {
  52. return 301 $scheme://$host/remote.php/dav;
  53. }
  54. location = /.well-known/caldav {
  55. return 301 $scheme://$host/remote.php/dav;
  56. }
  57. # set max upload size
  58. client_max_body_size 10G;
  59. fastcgi_buffers 64 4K;
  60. # Enable gzip but do not remove ETag headers
  61. gzip on;
  62. gzip_vary on;
  63. gzip_comp_level 4;
  64. gzip_min_length 256;
  65. gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  66. 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;
  67. # Uncomment if your server is build with the ngx_pagespeed module
  68. # This module is currently not supported.
  69. #pagespeed off;
  70. location / {
  71. rewrite ^ /index.php$request_uri;
  72. }
  73. location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
  74. deny all;
  75. }
  76. location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
  77. deny all;
  78. }
  79. location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
  80. fastcgi_split_path_info ^(.+\.php)(/.*)$;
  81. include fastcgi_params;
  82. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  83. fastcgi_param PATH_INFO $fastcgi_path_info;
  84. # fastcgi_param HTTPS on;
  85. #Avoid sending the security headers twice
  86. fastcgi_param modHeadersAvailable true;
  87. fastcgi_param front_controller_active true;
  88. fastcgi_pass php-handler;
  89. fastcgi_intercept_errors on;
  90. fastcgi_request_buffering off;
  91. }
  92. location ~ ^/(?:updater|ocs-provider)(?:$|/) {
  93. try_files $uri/ =404;
  94. index index.php;
  95. }
  96. # Adding the cache control header for js and css files
  97. # Make sure it is BELOW the PHP block
  98. location ~ \.(?:css|js|woff2?|svg|gif)$ {
  99. try_files $uri /index.php$request_uri;
  100. add_header Cache-Control "public, max-age=15778463";
  101. # Add headers to serve security related headers (It is intended to
  102. # have those duplicated to the ones above)
  103. # Before enabling Strict-Transport-Security headers please read into
  104. # this topic first.
  105. # add_header Strict-Transport-Security "max-age=15768000;
  106. # includeSubDomains; preload;";
  107. #
  108. # WARNING: Only add the preload option once you read about
  109. # the consequences in https://hstspreload.org/. This option
  110. # will add the domain to a hardcoded list that is shipped
  111. # in all major browsers and getting removed from this list
  112. # could take several months.
  113. add_header X-Content-Type-Options nosniff;
  114. add_header X-XSS-Protection "1; mode=block";
  115. add_header X-Robots-Tag none;
  116. add_header X-Download-Options noopen;
  117. add_header X-Permitted-Cross-Domain-Policies none;
  118. add_header Referrer-Policy no-referrer;
  119. # Optional: Don't log access to assets
  120. access_log off;
  121. }
  122. location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
  123. try_files $uri /index.php$request_uri;
  124. # Optional: Don't log access to other assets
  125. access_log off;
  126. }
  127. }
  128. }