# Wejście do aplikacji po HTTPS (PRE-16). # # Poza bezpieczeństwem — Basic Auth po zwykłym http leci siecią czytelny dla # każdego, kto słucha — TLS naprawia DWIE funkcje zepsute dziś z tego samego # powodu: geolokalizacja przeglądarki („Tu i teraz") oraz kopiowanie promptu do # schowka działają wyłącznie w tzw. secure context i po http po prostu odmawiają. --- apiVersion: traefik.io/v1alpha1 kind: Middleware metadata: name: security-headers namespace: astrololo spec: headers: stsSeconds: 31536000 # HSTS: rok stsIncludeSubdomains: false # dotyczy tylko tego hosta stsPreload: false # preload to wpis na listę w przeglądarkach # — praktycznie nieodwracalny, nie wchodzimy forceSTSHeader: true # nagłówek także przy odpowiedziach z backendu contentTypeNosniff: true frameDeny: true referrerPolicy: same-origin --- apiVersion: traefik.io/v1alpha1 kind: Middleware metadata: name: redirect-https namespace: astrololo spec: redirectScheme: scheme: https permanent: true --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: astrololo namespace: astrololo annotations: traefik.ingress.kubernetes.io/router.entrypoints: websecure traefik.ingress.kubernetes.io/router.middlewares: astrololo-security-headers@kubernetescrd spec: tls: - hosts: [astrololo.czernobog.pl] secretName: astrololo-tls # wypełnia cert-manager (tls.yaml) rules: - host: astrololo.czernobog.pl http: paths: - path: / pathType: Prefix backend: service: { name: presentation, port: { number: 8000 } } --- # Osobny Ingress wyłącznie na porcie 80 — istnieje po to, żeby odesłać na https. # Rozdzielone świadomie: gdyby przekierowanie wisiało na tym samym routerze, co # wejście po https, odsyłałoby samo do siebie w kółko. Backend jest tu formalnością, # bo żadne żądanie do niego nie dojdzie. apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: astrololo-redirect namespace: astrololo annotations: traefik.ingress.kubernetes.io/router.entrypoints: web traefik.ingress.kubernetes.io/router.middlewares: astrololo-redirect-https@kubernetescrd spec: rules: - host: astrololo.czernobog.pl http: paths: - path: / pathType: Prefix backend: service: { name: presentation, port: { number: 8000 } } --- # ── astrodemo ────────────────────────────────────────────────────────────── # Osobny host, nie ścieżka pod astrololo.czernobog.pl. Ścieżka („/demo") dzieliłaby # z pełną aplikacją pochodzenie w rozumieniu przeglądarki, czyli i ciasteczka: # wejście do jednej ruszałoby sesję w drugiej. Osobny host trzyma je rozdzielnie. apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: astrodemo namespace: astrololo annotations: traefik.ingress.kubernetes.io/router.entrypoints: websecure traefik.ingress.kubernetes.io/router.middlewares: astrololo-security-headers@kubernetescrd spec: tls: - hosts: [astrodemo.czernobog.pl] secretName: astrololo-tls # ten sam certyfikat obejmuje oba hosty (tls.yaml) rules: - host: astrodemo.czernobog.pl http: paths: - path: / pathType: Prefix backend: service: { name: astrodemo, port: { number: 8005 } } --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: astrodemo-redirect namespace: astrololo annotations: traefik.ingress.kubernetes.io/router.entrypoints: web traefik.ingress.kubernetes.io/router.middlewares: astrololo-redirect-https@kubernetescrd spec: rules: - host: astrodemo.czernobog.pl http: paths: - path: / pathType: Prefix backend: service: { name: astrodemo, port: { number: 8005 } } --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: astroklient namespace: astrololo annotations: traefik.ingress.kubernetes.io/router.entrypoints: websecure traefik.ingress.kubernetes.io/router.middlewares: astrololo-security-headers@kubernetescrd spec: tls: - hosts: [astroklient.czernobog.pl] secretName: astrololo-tls # ten sam certyfikat obejmuje wszystkie hosty (tls.yaml) rules: - host: astroklient.czernobog.pl http: paths: - path: / pathType: Prefix backend: service: { name: astroklient, port: { number: 8006 } } --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: astroklient-redirect namespace: astrololo annotations: traefik.ingress.kubernetes.io/router.entrypoints: web traefik.ingress.kubernetes.io/router.middlewares: astrololo-redirect-https@kubernetescrd spec: rules: - host: astroklient.czernobog.pl http: paths: - path: / pathType: Prefix backend: service: { name: astroklient, port: { number: 8006 } }