nginx.conf 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # downloaded from https://raw.githubusercontent.com/nextcloud/docker/master/.examples/docker-compose/insecure/mariadb/fpm/web/nginx.conf
  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. # allow longer url, like when we want to download a lot of files
  61. large_client_header_buffers 4 64k;
  62. # Enable gzip but do not remove ETag headers
  63. gzip on;
  64. gzip_vary on;
  65. gzip_comp_level 4;
  66. gzip_min_length 256;
  67. gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  68. 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;
  69. # Uncomment if your server is build with the ngx_pagespeed module
  70. # This module is currently not supported.
  71. #pagespeed off;
  72. location / {
  73. rewrite ^ /index.php$request_uri;
  74. }
  75. location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
  76. deny all;
  77. }
  78. location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
  79. deny all;
  80. }
  81. location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
  82. fastcgi_split_path_info ^(.+\.php)(/.*)$;
  83. include fastcgi_params;
  84. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  85. fastcgi_param PATH_INFO $fastcgi_path_info;
  86. # fastcgi_param HTTPS on;
  87. #Avoid sending the security headers twice
  88. fastcgi_param modHeadersAvailable true;
  89. fastcgi_param front_controller_active true;
  90. fastcgi_pass php-handler;
  91. fastcgi_intercept_errors on;
  92. fastcgi_request_buffering off;
  93. }
  94. location ~ ^/(?:updater|ocs-provider)(?:$|/) {
  95. try_files $uri/ =404;
  96. index index.php;
  97. }
  98. # Adding the cache control header for js and css files
  99. # Make sure it is BELOW the PHP block
  100. location ~ \.(?:css|js|woff|svg|gif)$ {
  101. try_files $uri /index.php$request_uri;
  102. add_header Cache-Control "public, max-age=15778463";
  103. # Add headers to serve security related headers (It is intended to
  104. # have those duplicated to the ones above)
  105. # Before enabling Strict-Transport-Security headers please read into
  106. # this topic first.
  107. # add_header Strict-Transport-Security "max-age=15768000;
  108. # includeSubDomains; preload;";
  109. #
  110. # WARNING: Only add the preload option once you read about
  111. # the consequences in https://hstspreload.org/. This option
  112. # will add the domain to a hardcoded list that is shipped
  113. # in all major browsers and getting removed from this list
  114. # could take several months.
  115. add_header X-Content-Type-Options nosniff;
  116. add_header X-XSS-Protection "1; mode=block";
  117. add_header X-Robots-Tag none;
  118. add_header X-Download-Options noopen;
  119. add_header X-Permitted-Cross-Domain-Policies none;
  120. # Optional: Don't log access to assets
  121. access_log off;
  122. }
  123. location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
  124. try_files $uri /index.php$request_uri;
  125. # Optional: Don't log access to other assets
  126. access_log off;
  127. }
  128. }
  129. }