nginx-config.yaml 7.5 KB

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