'Is it possible to redirect storage requests? Using a proxy

I have NGINX running in my docker, which allows me to redirect requests to the right container by the $http_host header.

Example:

  • curl app2-server-container:8080
  • curl app1-server-container:8080

Is it possible to redirect requests to containers running in the docker this way:

  • psql postgresql://user:pass@app1-postgres-container:5432/name_db
  • psql postgresql://user:pass@app2-postgres-container:5432/name_db

The problem is that NGINX stream proxy allows to redirect traffic but doesn't allow to pass destination point.

First of all, I'm interested in a more universal solution that could work with Redis, ClickHouse, etc.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source