WhatsApp / WhatsApp-Business-API-Setup-Scripts

The scripts related to setting up WhatsApp business API
MIT License
410 stars 433 forks source link

Deploy behind reverse proxy #40

Open marcocaberletti opened 4 years ago

marcocaberletti commented 4 years ago

Hi! I should deploy many different WhatsApp API instances behind a reverse proxy, using different paths to route the traffic. Every instance is a different host with a docker-compose stack.

So, for example:

my.domain.example/client-1 ---> instance-1
my.domain.example/client-2 ---> instance-2

I try to do this setup, but I get this error:

app.ERROR: [b278a05bed9347d9b0295ebaf9da6e75] Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /client-1" (uncaught exception) at /var/www/html/vendor/symfony/http-kernel/EventListener/RouterListener.php line 2 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /client-1\" at /var/www/html/vendor/symfony/http-kernel/EventListener/RouterListener.php:2, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): No routes found for \"/client-1\". at /var/www/html/vendor/symfony/routing/Matcher/UrlMatcher.php:2)"} []

Can you help me?

mengyiyuan commented 4 years ago

@marcocaberletti can you elaborate more on how you set up these different instances?

  1. are they using the same db host? if so, you need to set the WA_DB_HOSTNAME env var according to https://developers.facebook.com/docs/whatsapp/guides/mysql
  2. is each instance running with a different phone number?
marcocaberletti commented 4 years ago

@mengyiyuan in my setup, every instance is independent. Every instance is a EC2 instance with its own DB and run with different phone number. Currently, I create a new DNS name for every instance:

client-1.domain.example --> instance-1
client-2.domain.example --> instance-2

My goal is to use a single DNS name and use a different path to "select" the client:

wa.domain.example/client-1 --> instance-1
wa.domain.example/client-2 --> instance-2