{
  "node": {
    "id": "{{ .EnvoyConfigOpt.NodeID }}",
    "cluster": "mycluster",
    "locality": {
      "zone": "testzone"
    },
    "metadata": {
      {{ .EnvoyConfigOpt.meta_json_str }}
    }
  },
  "stats_config": {
    "use_all_default_tags": false
  },
  "admin": {
    "access_log_path": "{{.AccessLogPath}}",
    "address": {
      "socket_address": {
        "address": "0.0.0.0",
        "port_value": {{.Ports.AdminPort}}
      }
    }
  },
  "layered_runtime": {
      "layers": [
          {
              "name": "deprecation",
              "static_layer": {
                  "envoy.deprecated_features:envoy.config.listener.v3.Listener.hidden_envoy_deprecated_use_original_dst": true,
                  "re2.max_program_size.error_level": 1024
              }
          },
          {
              "name": "admin",
              "admin_layer": {}
          }
      ]
  },
  "dynamic_resources": {
    "lds_config": {
      "resource_api_version": "V3",
      "ads": {}
     },
    "cds_config": {
      "resource_api_version": "V3",
      "ads": {}
    },
    "ads_config": {
      "api_type": "GRPC",
      "transport_api_version": "V3",
      "grpc_services": {
        "envoy_grpc": {
          "cluster_name": "xds-grpc"
        }
      },
      "refresh_delay": {
        "seconds": 30,
        "nanos": 0
      }
    }
  },
  "static_resources": {
    "listeners": [
    {
    "name": "http_0.0.0.0_{{.Ports.ServerProxyPort}}",
    "address": {
      "socket_address": {
        "address": "0.0.0.0",
        "port_value": {{.Ports.ServerProxyPort}}
      }
    },
    "filter_chains": [
      {
        "filters": [
          {
            "name": "envoy.filters.network.http_connection_manager",
            "typed_config": {
              "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
              "stat_prefix": "http",
              "route_config": {
                  "name": "default",
                  "virtual_hosts": [
                      {
                        "name": "backend",
                        "domains": [
                          "*"
                        ],
                        "routes": [
                          {
                            "match": {
                              "prefix": "/"
                            },
                            "route": {
                              "cluster": "service1"
                            }
                          }
                        ]
                      }

                  ]
               },
               "http_filters": [
              {
              "name": "envoy.cors"
              },
              {
              "name": "envoy.filters.http.router"
              }
              ]
            }
          }
        ]
      }
    ]
  },
    {
    "name": "http_0.0.0.0_{{.Ports.ClientProxyPort}}",
    "address": {
      "socket_address": {
        "address": "0.0.0.0",
        "port_value": {{.Ports.ClientProxyPort}}
      }
    },
    "filter_chains": [
      {
        "filters": [
          {
            "name": "envoy.filters.network.http_connection_manager",
            "typed_config": {
              "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
              "stat_prefix": "http",
              "route_config": {
                  "name": "default",
                  "virtual_hosts": [
                      {
                        "name": "backend",
                        "domains": [
                          "*"
                        ],
                        "routes": [
                          {
                            "match": {
                              "prefix": "/"
                            },
                            "route": {
                              "cluster": "service2"
                            }
                          }
                        ]
                      }

                  ]
               },
               "http_filters": [
              {
              "name": "envoy.cors"
              },
              {
              "name": "envoy.filters.http.router"
              }
              ]


            }
          }
        ]
      }
    ]
  },
    {
        "name": "tcpproxy",
        "address": {
          "socket_address": {
            "address": "0.0.0.0",
            "port_value": {{.Ports.TCPProxyPort}}
          }
        },
        "filter_chains": [
          {
            "filters": [
              {
                "name": "envoy.tcp_proxy",
                "typed_config": {
                "@type": "type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy",
                  "stat_prefix": "tcpproxy",
                  "cluster": "service1"
                }
              }
            ]
          }
        ]
      },
      {
        "name": "http_proxy_80",
        "address": {
          "socket_address": {
            "address": "0.0.0.0",
            "port_value": 17002
          }
         },

          "filter_chains": [
          {
            "filters": [
              {
                "name": "envoy.filters.network.http_connection_manager",
                "typed_config": {
                  "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
                  "codec_type": "AUTO",
                  "stat_prefix": "http_proxy",
                  "http_filters": [
                    {"name": "envoy.filters.http.router"
                    }
                  ],
                  "rds": {
                      "route_config_name": "80",
                       "config_source": {"resource_api_version": "V3","ads": {}}
                  },
                  "http_protocol_options": {
                    "allow_absolute_url": true
                  },
             "access_log": [
                {
                  "name": "envoy.access_loggers.file",
                  "typedConfig": {
                    "@type": "type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog",
                      "path":  "{{.AccessLogPath}}"
                   }
                }
              ]

                }
              }
            ]
          }
        ]
      },
      {
        "name": "http_proxy_all",
        "address": {
          "socket_address": {
            "address": "0.0.0.0",
            "port_value": 17003
          }
         },

          "filter_chains": [
          {
            "filters": [
              {
                "name": "envoy.filters.network.http_connection_manager",
                "typed_config": {
                  "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
                  "codec_type": "AUTO",
                  "stat_prefix": "http_proxy",
                  "http_filters": [
                    {"name": "envoy.filters.http.router"
                    }
                  ],
                  "rds": {
                      "route_config_name": "http_proxy",
                       "config_source": {"resource_api_version": "V3","ads": {}}
                  },
                  "http_protocol_options": {
                    "allow_absolute_url": true
                  },
             "access_log": [
                {
                  "name": "envoy.access_loggers.file",
                  "typedConfig": {
                      "@type": "type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog",
                      "path":  "{{.AccessLogPath}}"
                   }
                }
              ]

                }
              }
            ]
          }
        ]
      }
    ],
    "clusters": [
      {
        "name": "xds-grpc",
        "type": "STRICT_DNS",
        "connect_timeout": {
          "seconds": 5,
          "nanos": 0
        },
        "lb_policy": "ROUND_ROBIN",
         "load_assignment": {
           "cluster_name": "xds-grpc",
           "endpoints": [{
             "lb_endpoints": [{
               "endpoint": {
                 "address":{
                   "socket_address": {
                     "address": "127.0.0.1",
                     "port_value": {{.Ports.PilotGrpcPort}}
                   }
                 }
               }
             }]
           }]
         },
        "http2_protocol_options": {}
      },
      {
      "name": "service1",
      "type": "STRICT_DNS",
      "connect_timeout": {
        "seconds": 5,
        "nanos": 0
      },
      "lb_policy": "ROUND_ROBIN",
      "load_assignment": {
        "cluster_name": "service1",
        "endpoints": [{
          "lb_endpoints": [{
            "endpoint": {
              "address":{
                "socket_address": {
                  "address": "127.0.0.1",
                  "port_value": {{.Ports.BackendPort}}
                }
              }
            }
          }]
        }]
      },
      "http2_protocol_options": {}
      },
      {
      "name": "service2",
      "type": "STRICT_DNS",
      "connect_timeout": {
        "seconds": 5,
        "nanos": 0
      },
      "lb_policy": "ROUND_ROBIN",
      "load_assignment": {
        "cluster_name": "service2",
        "endpoints": [{
          "lb_endpoints": [{
            "endpoint": {
              "address":{
                "socket_address": {
                  "address": "127.0.0.1",
                  "port_value": {{.Ports.ServerProxyPort}}
                }
              }
            }
          }]
        }]
      },
      "http2_protocol_options": {}
      },
    ]
  }
}
