Botpress - Nginx Reverse Proxy

Hey there fellas,

I am thinking of setting up multiple chatbots as in a containerized platform lets say docker or Kubernetes, and I would want to be able to access these chatbots through a reverse proxy such as Nginx. any help is appreciated.

My example scenario

I have a multiple chatbots, lets call them Bravo, Charlie, Delta

  • Bravo’s IP address and port is 10.0.0.2:8080
  • Charlie’s IP : 10.0.0.3:8080
  • Delta’s IP :10.0.0.4:8080

All of these bots are living in containers behind a nginx proxy.
Now if I want to access these chatbots, I am able to get to the browser with 10.0.0.2:8080 and use the chatbots,

If I could setup a domain (alpha,org) and want to access these chatbots as alpha,com/bravo , or alpha,com/charlie and alpha,com/delta how would I be able to achieve this.?

The Proxy pass directive works only for the index_html and the chatbot application seems to have some kind of base url path that I am unable to figure out.
nginx returns a blank page if I inspect the traffic. Help me debug this.

Hey @chronograph3r!

I’m by no means an Nginx expert, but I can try to help you.

What you can do is instruct Nginx to redirect to the url http://{chatbot name}:8080/lite/{chatbot id}/?m=channel-web&v=Fullscreen depending on the inbound request’s path.

For example:

I’m not sure how you can achieve this with Nginx though.

Hey Thanks for the Reply @spgin ,

I am able to get to the container with their IP addresses. I need to be able to understand how the requests to the chatbots are redirected. Like is it possible that the botpress has some config file that has a baseurl path defined for how the requests are received and sent back?

There is no config in Botpress that allows you to modify the URL path at which a chatbot will answer HTTP calls.

What you could do is embed you bot in a HTML page (see instructions here https://botpress.io/docs/channels/web).

This way, the web page hosted at http://alpha.org/charlie could embed the chatbot that is hosted at http://10.0.0.3:8080/lite/charlie/?m=channel-web&v=Fullscreen

Here is the config we use to proxy 3 botpress, I’m omitting security and ssl details for clarity :

server {
  listen 443 http2 ssl;
  server_name  bravo.yourdomain.com;
  location ~ .*/assets/.* {
    proxy_cache bravo;
    proxy_ignore_headers Cache-Control;
    proxy_hide_header Cache-Control;
    proxy_hide_header Pragma;
    proxy_pass http://10.0.0.2:8080;
    proxy_cache_valid any 30m;
    proxy_set_header Cache-Control max-age=30;
    add_header Cache-Control max-age=30;
  }

  # We need to add specific headers so the websockets can be set up through the reverse proxy
  location /socket.io/ {
    proxy_pass http://10.0.0.2:8080/socket.io/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
  }
  location / {
    proxy_pass http://10.0.0.2:8080;
  }
}

You will need this config for each upstream (bravo, charlie, delta).

Thanks for the reply @PierrePaul I will try this solution and let you know if it works.