server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

server {
    listen              443 ssl;
    server_name         _;

    ssl_certificate     /dojo/certs/server.crt;
    ssl_certificate_key /dojo/certs/server.key;

    sendfile on;

    default_type application/octet-stream;

    gzip on;
    gzip_http_version 1.1;
    gzip_disable      "MSIE [1-6]\.";
    gzip_min_length   1100;
    gzip_vary         on;
    gzip_proxied      expired no-cache no-store private auth;
    gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_comp_level   9;

    large_client_header_buffers 4 1024k;
    client_max_body_size 100M;

    resolver 127.0.0.11;

    location /dojo/ {
        rewrite ^ $request_uri;
        rewrite ^/dojo(/.*) $1 break;
        return 400;
        proxy_pass http://dojo-frontend$uri;

        proxy_intercept_errors  on;
        proxy_http_version      1.1;
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection 'upgrade';
        proxy_set_header        Host $host;
        proxy_cache_bypass      $http_upgrade;
        proxy_buffering         off;
        proxy_read_timeout      999999;
    }

    location /dojo/api/ {
        rewrite ^ $request_uri;
        rewrite ^/dojo/api(/.*) $1 break;
        return 400;
        proxy_pass http://dojo-api:30993$uri;

        proxy_intercept_errors  on;
        proxy_http_version      1.1;
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection 'upgrade';
        proxy_set_header        Host $host;
        proxy_cache_bypass      $http_upgrade;
        proxy_buffering         off;
        proxy_read_timeout      999999;
    }

    location /dojo/adminer/ {
        rewrite ^ $request_uri;
        rewrite ^/dojo/adminer(/.*) $1 break;
        return 400;
        proxy_pass http://adminer:8080$uri;

        proxy_set_header        X-Real-IP  $remote_addr;
        proxy_set_header        X-Forwarded-For $remote_addr;
        proxy_intercept_errors  on;
        proxy_http_version      1.1;
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection 'upgrade';
        proxy_set_header        Host $host;
        proxy_cache_bypass      $http_upgrade;
        proxy_buffering         off;
        proxy_read_timeout      999999;
    }
}
