UNPKG

@softvisio/core

Version:
57 lines (46 loc) 2.23 kB
server { <% if ( localAddress ) { -%> listen "<%- localAddress %>"<%- server.isDefaultServer ? " default_server reuseport" : "" %><%- server.ssl ? " ssl" : "" %><%- server.proxyProtocol ? " proxy_protocol" : "" %>; <% } else { -%> <% if ( nginx.listenIpV4 ) { -%> listen *:<%- server.port %><%- server.isDefaultServer ? " default_server reuseport" : "" %><%- server.ssl ? " ssl" : "" %><%- server.proxyProtocol ? " proxy_protocol" : "" %>; <% } -%> <% if ( nginx.listenIpV6 ) { -%> listen [::]:<%- server.port %><%- server.isDefaultServer ? " default_server reuseport" : "" %><%- server.ssl ? " ssl" : "" %><%- server.proxyProtocol ? " proxy_protocol" : "" %>; <% } -%> <% } -%> <% if ( !server.isDefaultServer ) { -%> server_name <%- serverName.name %>; <% } -%> <% if ( server.ssl ) { -%> ssl_certificate "<%- serverName.certificatePath %>"; ssl_certificate_key "<%- serverName.privateKeyPath %>"; ssl_stapling <%- serverName.isSelfSignedCertificate ? "off" : "on" %>; ssl_stapling_verify <%- serverName.isSelfSignedCertificate ? "off" : "on" %>; <% } -%> <% if ( server.httpsRedirectPort ) { -%> location / { return 301 <%- server.httpsRedirectUrl %>; } <% } else { -%> real_ip_header <%- server.proxyProtocol ? "proxy_protocol" : nginx.config.realIpHeader %>; client_max_body_size <%- server.maxBodySize %>; location @backend { proxy_pass "http://<%- server.proxy.id %>"; proxy_cache <%- server.cacheEnabled ? `"main"` : "off" %>; proxy_cache_bypass <%- server.cacheBypass ? "$http_cache_control" : 0 %>; <% if ( server.hstsMaxAge ) { -%> add_header Strict-Transport-Security "max-age=<%- server.hstsMaxAge %>;<%- server.hstsSubdomains ? " includeSubDomains" : "" %>" always; <% } -%> } location / { error_page 418 = @backend; return 418; } <% } -%> <% if ( server.acmeLocation ) { -%> location <%- nginx.app.acme.httpLocation %> { proxy_pass "http://<%- nginx.privateHrrpServerUpstream %>"; } <% } -%> }