nginx-configmap.yaml 3.2 KB

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