pid {{ parameter_dict['pid-file'] }};
error_log {{ parameter_dict['error-log'] }};

daemon off;

events {
  worker_connections 1024;
  accept_mutex off;
}

http {
     default_type application/octet-stream;
     access_log {{ parameter_dict['access-log'] }} combined;
     client_max_body_size 10M;
     map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
     }

     server {
        listen [{{ parameter_dict['ipv6'] }}]:{{ parameter_dict['ssl-port'] }} ssl;
        server_name _;
        ssl_certificate     {{ parameter_dict['ssl-certificate'] }};
        ssl_certificate_key {{ parameter_dict['ssl-key'] }};
        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers         ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;
        keepalive_timeout 90s;

        location / {
            proxy_redirect off;
            proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host  $http_host;
            proxy_connect_timeout 200;

            proxy_pass {{ parameter_dict['repman-secure-url'] }};
        }
    }

    server {
        listen [{{ parameter_dict['ipv6'] }}]:{{ parameter_dict['port'] }};
        server_name _;

        location / {
            proxy_redirect off;
            proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host  $http_host;
            proxy_connect_timeout 200;

            proxy_pass {{ parameter_dict['repman-url'] }};
        }
    }
}
