<commit_before>apiVersion: networking.gke.io/v1beta1
kind: FrontendConfig
metadata:
  name: root-ingress-frontend-config
spec:
  redirectToHttps:
    enabled: true
    responseCodeName: MOVED_PERMANENTLY_DEFAULT
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: root-ingress
  annotations:
    kubernetes.io/ingress.class: "gce"
    cert-manager.io/cluster-issuer: reactive-trader-issuer
    external-dns.alpha.kubernetes.io/hostname: "*.lb.adaptivecluster.com"
    networking.gke.io/v1beta1.FrontendConfig: "root-ingress-frontend-config"
spec:
  tls:
  - hosts:
    - reactivetrader.com
    - "*.reactivetrader.com"
    - "*.adaptivecluster.com"
    - "*.lb.adaptivecluster.com"
    - "*.beta.lb.adaptivecluster.com"
    secretName: reactive-trader-tls

  backend:
    serviceName: gateway
    servicePort: 80
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: gateway-config
data:
  default.conf: |
    map $sent_http_content_type $expires {
      default                off;
      text/html              epoch;
      text/css               max;
      application/javascript max;
    }

    server {
      listen 8080;
      server_name reactivetrader.com;
      return 301 $scheme://www.reactivetrader.com$request_uri;
    }

    server {
      listen 8080;
      expires $expires;
      server_name www.reactivetrader.com ~^(?<namespace>(dev|uat))\.reactivetrader.com ~^web-(?<namespace>(demo|uat|dev))\.adaptivecluster.com ~^(?<namespace>[^\.]+?)\.(beta\.)?lb.adaptivecluster.com$;
      resolver kube-dns.kube-system.svc.cluster.local valid=5s;

      set $client_upstream "client";

      if ($host = "www.reactivetrader.com") {
        set $namespace "demo";
      }

      if ($host ~ "^[^\.]+\.beta\.") {
        set $client_upstream "new-client";
      }

      proxy_http_version 1.1;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      location /ws {
        proxy_pass http://broker.$namespace.svc.cluster.local:15674/ws;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
      }

      location / {
        proxy_pass http://$client_upstream.$namespace.svc.cluster.local:3000$request_uri;
      }
    }
<commit_msg>feat: update caching and compression on gateway proxy<commit_after>apiVersion: networking.gke.io/v1beta1
kind: FrontendConfig
metadata:
  name: root-ingress-frontend-config
spec:
  redirectToHttps:
    enabled: true
    responseCodeName: MOVED_PERMANENTLY_DEFAULT
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: root-ingress
  annotations:
    kubernetes.io/ingress.class: "gce"
    cert-manager.io/cluster-issuer: reactive-trader-issuer
    external-dns.alpha.kubernetes.io/hostname: "*.lb.adaptivecluster.com"
    networking.gke.io/v1beta1.FrontendConfig: "root-ingress-frontend-config"
spec:
  tls:
  - hosts:
    - reactivetrader.com
    - "*.reactivetrader.com"
    - "*.adaptivecluster.com"
    - "*.lb.adaptivecluster.com"
    - "*.beta.lb.adaptivecluster.com"
    secretName: reactive-trader-tls

  backend:
    serviceName: gateway
    servicePort: 80
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: gateway-config
data:
  default.conf: |
    map $sent_http_content_type $expires {
      default   max;
      text/html epoch;
    }

    server {
      listen 8080;
      server_name reactivetrader.com;
      return 301 $scheme://www.reactivetrader.com$request_uri;
    }

    server {
      listen 8080;
      server_name www.reactivetrader.com ~^(?<namespace>(dev|uat))\.reactivetrader.com ~^web-(?<namespace>(demo|uat|dev))\.adaptivecluster.com ~^(?<namespace>[^\.]+?)\.(beta\.)?lb.adaptivecluster.com$;
      resolver kube-dns.kube-system.svc.cluster.local valid=5s;

      set $client_upstream "client";

      if ($host = "www.reactivetrader.com") {
        set $namespace "demo";
      }

      if ($host ~ "^[^\.]+\.beta\.") {
        set $client_upstream "new-client";
      }

      expires $expires;

      gzip on;
      gzip_buffers 16 8k;
      gzip_comp_level 6;
      gzip_types text/plain text/html text/css application/javascript application/json;

      proxy_http_version 1.1;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      location /ws {
        proxy_pass http://broker.$namespace.svc.cluster.local:15674/ws;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
      }

      location / {
        proxy_pass http://$client_upstream.$namespace.svc.cluster.local:3000$request_uri;
      }
    }

{'fraction_non_alphanumeric': 0.1255195344970906, 'fraction_numerical': 0.014546965918536992, 'mean_word_length': 2.8752012882447664, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3307106', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1652, 'n_words': 270}