Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Path Manipulation (ProxyPass and ProxyPassReverse)

Jason Kölker edited this page May 31, 2019 · 2 revisions

Path Manipulation like ProxyPass and ProxyPassReverse in Apache httpd

Different applications can be deployed to serve up on different url paths. In the following deployments, a root app serves up content for / while an api app serves up content for /api:

root.json

{
  "id": "/root",
  "user":"root",
  "cmd": "echo 'root' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx"
    }
  },
  "cpus": 0.1,
  "instances": 4,
  "labels": {
    "HAPROXY_0_GROUP": "external",
    "HAPROXY_0_HTTP_BACKEND_PROXYPASS_PATH": "/",
    "HAPROXY_0_HTTP_BACKEND_REVPROXY_PATH": "/",
    "HAPROXY_0_PATH": "/",
    "HAPROXY_0_VHOST": "vhost.example.com",
    "HAPROXY_0_ENABLED": "true"
  },
  "mem": 32,
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "requirePorts": false
}

api.json

{
  "id": "/api",
  "user":"root",
  "cmd": "echo 'api' > /usr/share/nginx/html/index.html; nginx -g 'daemon off;'",
  "container": {
    "portMappings": [
      {
        "containerPort": 80,
        "hostPort": 0,
        "protocol": "tcp"
      }
    ],
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "nginx"
    }
  },
  "cpus": 0.1,
  "instances": 4,
  "labels": {
    "HAPROXY_0_GROUP": "external",
    "HAPROXY_0_HTTP_BACKEND_PROXYPASS_PATH": "/api",
    "HAPROXY_0_HTTP_BACKEND_REVPROXY_PATH": "/",
    "HAPROXY_0_PATH": "/api",
    "HAPROXY_0_VHOST": "vhost.example.com",
    "HAPROXY_0_ENABLED": "true"
  },
  "mem": 32,
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "requirePorts": false
}