
<% for (var idx = 0; idx < servers.length; idx++) {
    var s = servers[idx];
%>

    server {

        listen       80;

    <%
    if (s.hasSsl) {
    %>
        listen              443 ssl;
        ssl_certificate     <%-s.crtPath%>;
        ssl_certificate_key <%-s.keyPath%>;
    <%
    }
    %>


        server_name  <%-s.publicDomain%>;

        resolver 127.0.0.11 valid=10s;
        set $upstream http://<%-s.localDomain%>;

        location / {
            proxy_pass $upstream;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        # change to this to allow the applications to serve well-known files as well https://stackoverflow.com/questions/869001/how-to-serve-all-existing-static-files-directly-with-nginx-but-proxy-the-rest-t
        location /.well-known/ {
            root <%-s.staticWebRoot%>;
        }

    }

<%
}
%>