apocas / docker-modem

Docker Remote API network stack driver.
Apache License 2.0
234 stars 112 forks source link

Add pathPrefix option #101

Closed rumkin closed 1 year ago

rumkin commented 5 years ago

This commit add path prefix for nested HTTP APIs with customized routing. For example I can mount docker's api proxy to /system/docker/ on my server.

Also:

arnaud-dumont-vcgs commented 3 years ago

This would be useful as well to be able to use dockerode against Portainer, which acts as a reverse-proxy to the Docker daemon's Docker Engine API (see here), but under a sub-path:
e.g. http://<portainerHost>:9000/api/endpoints/<endPointId>/docker/

So then we could do:

var docker = new Docker({
  protocol: 'http',
  host: '<portainerHost>',
  headers:{
    // previously-retrieved Portainer auth token, from the Portainer API
    Authorization: 'Bearer <jwtToken>'
  },
  port: 9000,
  // previously retrieved Portainer endpointId for the target Docker daemon, from the Portainer API
  pathPrefix: '/api/endpoints/<endPointId>'
});