nginx.conf 5.8 KB

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