kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-proxy-web-and-blog
  namespace: asyncy-system
data:
  asyncy.com.conf: |-
    upstream product {
        ip_hash;
        server asyncy-homepage.netlify.com:443;
    }

    upstream blog {
        ip_hash;
        server ghost.blog.asyncy.com:443;
    }

    server {
        listen 8089;
        server_name blog.asyncy.com;
        server_tokens off;
        return 301 https://asyncy.com/blog$request_uri;
    }

    server {
        listen 8089;
        server_name www.asyncy.com;
        server_tokens off;
        return 301 https://asyncy.com$request_uri;
    }

    server {
        listen 8089;
        server_name asyncy.com;
        server_tokens off;
        return 301 https://storyscript.io$request_uri;
    }

    server {
        listen 8089;
        server_tokens off;
        server_name ~^(.*)\.asyncy\.com$;
        return 301 https://$1.storyscript.io$request_uri;
    }

    server {
        listen 8089;
        server_name storyscript.com;
        server_tokens off;
        return 307 https://storyscript.io$request_uri;
    }

    server {
        listen 8089;
        server_tokens off;
        server_name ~^(.*)\.storyscript\.com$;
        return 307 https://$1.storyscript.io$request_uri;
    }

    server {
        listen 8089;
        server_tokens off;
        server_name ~^(.*)\.asyncyapp\.com$;
        return 301 https://$1.storyscriptapp.com$request_uri;
    }

    server {
        listen 8089;
        server_tokens off;
        server_name api.hub.asyncy.com;
        return 301 https://api.hub.storyscript.io$request_uri;
    }

    server {
        listen 8089;
        server_tokens off;
        server_name status.asyncy.com;
        return 301 https://status.storyscript.io$request_uri;
    }

    server {
        listen 8089;
        server_tokens off;
        server_name storyscri.pt;
        return 301 https://storyscript.io$request_uri;
    }

    server {
        listen 8089;
        server_name storyscript.io;
        server_tokens off;

        location /blog {
            proxy_set_header Host storyscript.io;
            # The following is not a secret, but just an ID that can be checked
            # on the other side, to keep the crawlers at bay.
            proxy_set_header X-Blog-Proxy-ID 082wZ6iX;
            proxy_pass https://blog;
        }

        location / {
            proxy_set_header Host storyscript.io;
            proxy_pass https://product;
        }
    }
