{
  "apps": {
    "http": {
      "servers": {
        "apx.apxtri.farm.ants": {
          "listen": [":80",":443"],
          "tls_connection_policies": [
            {
              "match": {
                "sni": ["apx.apxtri.farm.ants"]
              },
              "certificates": {
                "load_storage": "local_certs"
              }
            }
          ],
          "routes": [
            {
              "match": [{
                "path": ["/trk/*"]
              }],
              "handle": [
                {
                  "handler": "subroute",
                  "routes": [
                    {
                      "match": [{
                        "path": ["/trk/redirect"]
                      }],
                      "handle": [{
                        "handler": "static_response",
                        "status_code": 301,
                        "headers": {
                          "Location": ["{http.request.uri.query.url}"]
                        }
                      }]
                    },
                    {
                      "match": [{
                         "path": ["/trk/*"]
                      }],
                      "handle": [
                        {
                          "handler": "rewrite",
                          "uri": "/{http.request.uri.path_elements.1}" 
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "match": [{
                "path": ["/apxtri/Checkjson.js"]
              }],
              "handle": [{
                "handler": "file_server",
                "root": "/media/phil/usbfarm/apxtowns/farm-ants/apxtri/apxtri/models/"
              }],
              "terminal": true 
            },
            {
              "match": [{
                "path": ["/setup.sh"]
              }],
              "handle": [{
                "handler": "file_server",
                "root": "/media/phil/usbfarm/apxtowns/adminapi/apxtri/setup/"
              }],
              "terminal": true
            },
            {
              "match": [{
                "path_regexp": {
                  "pattern": "^/([^/]+)/(setup.*\\.tar\\.gz)$"
                }
              }],
              "handle": [{
                "handler": "rewrite",
                "uri": "/{http.matchers.path_regexp.1}/backups/{http.matchers.path_regexp.2}"
              },
              {
                "handler": "file_server",
                "root": "/media/phil/usbfarm/apxtowns/farm-ants/"
              }],
              "terminal": true
            },
            {
              "match": [{
                "path_regexp": {
                  "pattern": "/objectimg/(.*)/img/"
                }
              }],
              "handle": [{
                "handler": "rewrite",
                "uri": "/{http.matchers.path_regexp.1}" 
              },
              {
                "handler": "file_server",
                "root": "/media/phil/usbfarm/apxtowns/data/apxtri/objects/"
              }],
              "terminal": true
            },
            {
              "match": [{
                "path": ["/cdn/*"]
              }],
              "handle": [
                {
                  "handler": "rewrite",
                  "strip_path_prefix": "/cdn"
                },
                {
                  "handler": "file_server",
                  "root": "/media/phil/usbfarm/apxtowns/data/apxtri/objects/wwws/cdn/"
                }
              ],
              "terminal": true
            },
            {
              "match": [{
                "path": ["/api/*"]
              }],
              "handle": [
                {
                  "handler": "rewrite",
                  "strip_path_prefix": "/api"
                },
                {
                  "handler": "reverse_proxy",
                  "upstreams": [{
                    "dial": "localhost:3021"
                  }]
                }
              ],
              "terminal": true
            },
            {
              "match": [{
                "path": ["/socket/*"]
              }],
              "handle": [{
                "handler": "reverse_proxy",
                "upstreams": [{
                  "dial": "127.0.0.1:3031"
                }],
                "headers": {
                  "request": {
                    "set": {
                      "Upgrade": ["{http.request.header.Upgrade}"],
                      "Connection": ["upgrade"]
                    }
                  }
                }
              }],
              "terminal": true
            },
            {
              "match": [{
                "path": ["/apidoc"]
              }],
              "handle": [{
                "handler": "static_response",
                "status_code": 301,
                "headers": {
                  "Location": ["/apidoc/"]
                }
              }],
              "terminal": true
            },
            {
              "match": [{
                "path": ["/apidoc/", "/apidoc/*"] 
              }],
              "handle": [{
                "handler": "file_server",
                "root": "/media/phil/usbfarm/apxtowns/data/apxtri/objects/wwws/apidoc/",
                "index_names": ["index.html"]
              }],
              "terminal": true
            },
            {
              "match": [{
                "path": ["/src/*"]
              }],
              "handle": [
                {
                  "handler": "rewrite",
                  "strip_path_prefix": "/src"
                },
                {
                  "handler": "file_server",
                  "root": "/media/phil/usbfarm/apxtowns/data/apxtri/objects/wwws/apx/src/",
                  "index_names": ["index.html", "index_fr.html", "index_en.html"]
                }
              ],
              "terminal": true
            },
            {
              "match": [{
                "host": ["apx.apxtri.farm.ants"]
              }],
              "handle": [{
                "handler": "file_server",
                "root": "/media/phil/usbfarm/apxtowns/data/apxtri/objects/wwws/apx/dist",
                "index_names": ["index.html", "index_fr.html", "index_en.html"]
              }],
              "terminal": true
            }
          ]
        }
      }
    }
  }
}