apiVersion: v1
kind: ConfigMap
metadata:
  name: scopus-nginx-configmap
  namespace: reciter
  labels:
    app: reciter-scopus
    environment: dev
    owner: szd2013
data:
  nginx.conf: |-
    server {
        listen 80 default_server;
        listen [::]:80 default_server;

        location /scopus {
            rewrite ^/scopus/swagger-ui/index.html$ /swagger-ui/index.html break;
            rewrite ^/scopus/(.*)$ /scopus/$1 break;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header Host $host;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_connect_timeout 300s;
            proxy_pass http://localhost:5000;
        }


        location /webjars {
            proxy_pass http://localhost:5000;
            proxy_redirect off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header Host $host;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_connect_timeout 300s;
        }

        location /scopus/webjars {
            rewrite ^/scopus/(.*)$ /$1 break;
            proxy_pass http://localhost:5000;
            proxy_redirect off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header Host $host;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_connect_timeout 300s;
        }

        location /scopus/swagger {
            rewrite ^/scopus/(.*)$ /$1 break;
            proxy_pass http://localhost:5000;
            proxy_redirect off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header Host $host;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_connect_timeout 300s;
        }

        location /scopus/v2 {
            rewrite ^/scopus/(.*)$ /$1 break;
            proxy_pass http://localhost:5000;
            proxy_redirect off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header Host $host;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_connect_timeout 300s;
        }

        location / {
            proxy_pass http://localhost:5000;
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location /nginx-health {
            access_log off;
            return 200;
        }
    }
