static String nginxConfig(
            Path configTemplate,
            Path clientCert,
            Path clientKey,
            Path serverCert,
            Path serverKey,
            int vespaMtlsPort,
            int vespaTokenPort,
            List<String> tokenEndpoints,
            Path root,
            boolean useAzureProxy,
            boolean isDevEnvironment) {

        try {
            String nginxTemplate = Files.readString(configTemplate);

            String proxySuffix = useAzureProxy ? "" : "proxy_protocol";
            nginxTemplate = replace(nginxTemplate, "proxy_protocol_suffix", proxySuffix);

            nginxTemplate = replace(nginxTemplate, "client_cert", clientCert.toString());
            nginxTemplate = replace(nginxTemplate, "client_key", clientKey.toString());
            nginxTemplate = replace(nginxTemplate, "server_cert", serverCert.toString());
            nginxTemplate = replace(nginxTemplate, "server_key", serverKey.toString());
            nginxTemplate = replace(nginxTemplate, "vespa_mtls_port", Integer.toString(vespaMtlsPort));
            nginxTemplate = replace(nginxTemplate, "vespa_token_port", Integer.toString(vespaTokenPort));
            nginxTemplate = replace(nginxTemplate, "prefix", root.toString());
            String tokenmapping = tokenEndpoints.stream()
                    .map("        %s vespatoken;"::formatted)
                    .collect(Collectors.joining("\n"));
            nginxTemplate = replace(nginxTemplate, "vespa_token_endpoints", tokenmapping);

            String corsMap = isDevEnvironment ? """
                    map $http_origin $allow_origin {
                            ~^https://.*\\.vespa-cloud.com$ $http_origin;
                            ~^https?://localhost(:\\d+)?$ $http_origin;
                            default "";
                        }
                    """ : "";

            String corsHandler = isDevEnvironment ? """
                    if ($request_method = OPTIONS) {
                                  add_header Access-Control-Allow-Origin $allow_origin;
                                  add_header Vary Origin;
                                  add_header Access-Control-Allow-Headers "Origin,Content-Type,Accept,Authorization";
                                  add_header Access-Control-Allow-Methods "OPTIONS,GET,PUT,DELETE,POST,PATCH";
                                  add_header Access-Control-Max-Age "600";
                                  return 204;
                                }
                                add_header Access-Control-Allow-Origin $allow_origin;
                                add_header Vary Origin;
                    """ : "";

            nginxTemplate = replace(nginxTemplate, "cors_map", corsMap);
            nginxTemplate = replace(nginxTemplate, "cors_handler", corsHandler);

            // TODO: verify that all template vars have been expanded
            return nginxTemplate;
        } catch (IOException e) {
            throw new IllegalArgumentException("Could not create data plane proxy configuration", e);
        }
    }
Configures a data plane proxy. Currently using Nginx.

@author mortent
container-disc/src/main/java/com/yahoo/container/jdisc/DataplaneProxyService.java