nginx-configmap.yaml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: "nginx-configuration"
  5. data:
  6. protocol: {{ include "nginx.scheme" . }}
  7. {{ $timeout := 60 }}
  8. {{ $size := .Values.nextcloud.max_upload_size | default 3 }}
  9. {{ $externalAccessPort := printf ":%v" .Values.nginxConfig.externalAccessPort }}
  10. {{/* If its 443, do not append it on the rewrite at all */}}
  11. {{ if eq $externalAccessPort ":443" }}
  12. {{ $externalAccessPort = "" }}
  13. {{ end }}
  14. {{/* Safely access key as it is conditionaly shown */}}
  15. {{ if hasKey .Values "nginxConfig" }}
  16. {{ $timeout = .Values.nginxConfig.proxy_timeouts | default 60 }}
  17. {{ end }}
  18. nginx.conf: |-
  19. events {}
  20. http {
  21. # redirects all http requests to https requests
  22. server {
  23. listen 8000 default_server;
  24. listen [::]:8000 default_server;
  25. return 301 https://$host$request_uri;
  26. }
  27. server {
  28. server_name localhost;
  29. listen {{ .Values.service.nodePort }} ssl http2;
  30. listen [::]:{{ .Values.service.nodePort }} ssl http2;
  31. ssl_certificate '/etc/nginx-certs/public.crt';
  32. ssl_certificate_key '/etc/nginx-certs/private.key';
  33. # maximum 3GB Upload File; change to fit your needs
  34. client_max_body_size {{ $size }}G;
  35. add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" always;
  36. location = /robots.txt {
  37. allow all;
  38. log_not_found off;
  39. access_log off;
  40. }
  41. location = /.well-known/carddav {
  42. {{ if .Values.nginxConfig.useDifferentAccessPort }}
  43. return 301 $scheme://$host{{ $externalAccessPort }}/remote.php/dav;
  44. {{ else }}
  45. return 301 $scheme://$host:$server_port/remote.php/dav;
  46. {{ end }}
  47. }
  48. location = /.well-known/caldav {
  49. {{ if .Values.nginxConfig.useDifferentAccessPort }}
  50. return 301 $scheme://$host{{ $externalAccessPort }}/remote.php/dav;
  51. {{ else }}
  52. return 301 $scheme://$host:$server_port/remote.php/dav;
  53. {{ end }}
  54. }
  55. location / {
  56. proxy_pass http://localhost;
  57. proxy_http_version 1.1;
  58. proxy_cache_bypass $http_upgrade;
  59. proxy_request_buffering off;
  60. # Proxy headers
  61. proxy_set_header Upgrade $http_upgrade;
  62. proxy_set_header Connection "upgrade";
  63. proxy_set_header Host $http_host;
  64. proxy_set_header X-Real-IP $remote_addr;
  65. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  66. proxy_set_header X-Forwarded-Proto https;
  67. proxy_set_header X-Forwarded-Host $host;
  68. {{ if .Values.nginxConfig.useDifferentAccessPort }}
  69. proxy_set_header X-Forwarded-Port {{ .Values.nginxConfig.externalAccessPort }};
  70. {{ else }}
  71. proxy_set_header X-Forwarded-Port $server_port;
  72. {{ end }}
  73. # Proxy timeouts
  74. proxy_connect_timeout {{ $timeout }}s;
  75. proxy_send_timeout {{ $timeout }}s;
  76. proxy_read_timeout {{ $timeout }}s;
  77. }
  78. }
  79. }