configmap-https.yaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. {{- if and (ne .Values.expose.type "ingress") (ne .Values.expose.type "route") (.Values.expose.tls.enabled) }}
  2. {{- $scheme := (include "harbor.component.scheme" .) -}}
  3. apiVersion: v1
  4. kind: ConfigMap
  5. metadata:
  6. name: {{ template "harbor.nginx" . }}
  7. namespace: {{ .Release.Namespace | quote }}
  8. labels:
  9. {{ include "harbor.labels" . | indent 4 }}
  10. data:
  11. nginx.conf: |+
  12. worker_processes auto;
  13. pid /tmp/nginx.pid;
  14. events {
  15. worker_connections 3096;
  16. use epoll;
  17. multi_accept on;
  18. }
  19. http {
  20. client_body_temp_path /tmp/client_body_temp;
  21. proxy_temp_path /tmp/proxy_temp;
  22. fastcgi_temp_path /tmp/fastcgi_temp;
  23. uwsgi_temp_path /tmp/uwsgi_temp;
  24. scgi_temp_path /tmp/scgi_temp;
  25. tcp_nodelay on;
  26. # this is necessary for us to be able to disable request buffering in all cases
  27. proxy_http_version 1.1;
  28. upstream core {
  29. server "{{ template "harbor.core" . }}:{{ template "harbor.core.servicePort" . }}";
  30. }
  31. upstream portal {
  32. server "{{ template "harbor.portal" . }}:{{ template "harbor.portal.servicePort" . }}";
  33. }
  34. log_format timed_combined '[$time_local]:$remote_addr - '
  35. '"$request" $status $body_bytes_sent '
  36. '"$http_referer" "$http_user_agent" '
  37. '$request_time $upstream_response_time $pipe';
  38. access_log /dev/stdout timed_combined;
  39. map $http_x_forwarded_proto $x_forwarded_proto {
  40. default $http_x_forwarded_proto;
  41. "" $scheme;
  42. }
  43. server {
  44. {{- if .Values.ipFamily.ipv4.enabled }}
  45. listen 8443 ssl;
  46. {{- end}}
  47. {{- if .Values.ipFamily.ipv6.enabled }}
  48. listen [::]:8443 ssl;
  49. {{- end }}
  50. # server_name harbordomain.com;
  51. server_tokens off;
  52. # SSL
  53. ssl_certificate /etc/nginx/cert/tls.crt;
  54. ssl_certificate_key /etc/nginx/cert/tls.key;
  55. # Recommendations from https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
  56. ssl_protocols TLSv1.2 TLSv1.3;
  57. {{- if .Values.internalTLS.strong_ssl_ciphers }}
  58. ssl_ciphers ECDHE+AESGCM:DHE+AESGCM:ECDHE+RSA+SHA256:DHE+RSA+SHA256:!AES128;
  59. {{ else }}
  60. ssl_ciphers '!aNULL:kECDH+AESGCM:ECDH+AESGCM:RSA+AESGCM:kECDH+AES:ECDH+AES:RSA+AES:';
  61. {{- end }}
  62. ssl_prefer_server_ciphers on;
  63. ssl_session_cache shared:SSL:10m;
  64. # disable any limits to avoid HTTP 413 for large image uploads
  65. client_max_body_size 0;
  66. # required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)
  67. chunked_transfer_encoding on;
  68. # Add extra headers
  69. add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
  70. add_header X-Frame-Options DENY;
  71. add_header Content-Security-Policy "frame-ancestors 'none'";
  72. location / {
  73. proxy_pass {{ $scheme }}://portal/;
  74. proxy_set_header Host $http_host;
  75. proxy_set_header X-Real-IP $remote_addr;
  76. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  77. proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
  78. proxy_cookie_path / "/; HttpOnly; Secure";
  79. proxy_buffering off;
  80. proxy_request_buffering off;
  81. }
  82. location /api/ {
  83. proxy_pass {{ $scheme }}://core/api/;
  84. {{- if and .Values.internalTLS.enabled }}
  85. proxy_ssl_verify off;
  86. proxy_ssl_session_reuse on;
  87. {{- end }}
  88. proxy_set_header Host $host;
  89. proxy_set_header X-Real-IP $remote_addr;
  90. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  91. proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
  92. proxy_cookie_path / "/; Secure";
  93. proxy_buffering off;
  94. proxy_request_buffering off;
  95. }
  96. location /c/ {
  97. proxy_pass {{ $scheme }}://core/c/;
  98. proxy_set_header Host $host;
  99. proxy_set_header X-Real-IP $remote_addr;
  100. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  101. proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
  102. proxy_cookie_path / "/; Secure";
  103. proxy_buffering off;
  104. proxy_request_buffering off;
  105. }
  106. location /v1/ {
  107. return 404;
  108. }
  109. location /v2/ {
  110. proxy_pass {{ $scheme }}://core/v2/;
  111. proxy_set_header Host $http_host;
  112. proxy_set_header X-Real-IP $remote_addr;
  113. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  114. proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
  115. proxy_buffering off;
  116. proxy_request_buffering off;
  117. proxy_send_timeout 900;
  118. proxy_read_timeout 900;
  119. }
  120. location /service/ {
  121. proxy_pass {{ $scheme }}://core/service/;
  122. proxy_set_header Host $http_host;
  123. proxy_set_header X-Real-IP $remote_addr;
  124. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  125. proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
  126. proxy_cookie_path / "/; Secure";
  127. proxy_buffering off;
  128. proxy_request_buffering off;
  129. }
  130. location /service/notifications {
  131. return 404;
  132. }
  133. }
  134. server {
  135. {{- if .Values.ipFamily.ipv4.enabled }}
  136. listen 8080;
  137. {{- end}}
  138. {{- if .Values.ipFamily.ipv6.enabled }}
  139. listen [::]:8080;
  140. {{- end}}
  141. #server_name harbordomain.com;
  142. return 301 https://$host$request_uri;
  143. }
  144. }
  145. {{- end }}