Behind a proxy

What a reverse proxy, a load balancer or a CDN in front of your site must pass on to the chat.

With a reverse proxy, a load balancer or a CDN in front of your site, the proxy must pass three things on, and the chat must know which proxies to believe.

Your visitorA page of your siteAsks a questionProxy or CDNKeeps the host nameSends the visitor IPSays it was HTTPSYour web serverThe chat pathtrusted_proxies setOn the chat path: no buffering, no compression, no caching
Your visitorA page of your siteProxy or CDNKeeps the host nameSends the visitor IPSays it was HTTPSYour web serverThe chat pathtrusted_proxies setOn the chat path:no buffering, nocompression, no caching

The proxy passes the visitor’s host name, IP address and HTTPS on to your server, and lets the answer through as it is written.

01 · Tell the chat which proxies to believe

Add trusted_proxies to the front controller, with the addresses or ranges of your own proxies:

(new Opensolr\ChatBot\App([
    'data_dir'        => '/opt/opensolr-chat',
    'base_path'       => '/opensolr-chat',
    'trusted_proxies' => ['127.0.0.1', '10.0.0.0/8'],
]))->run();
  • With it, a request that comes from one of these addresses has its X-Forwarded-For (the visitor’s IP address) and its X-Forwarded-Proto (HTTPS) believed.
  • Without it, every visitor arrives with the proxy’s address, so they all share one set of limits and reach it together.
  • List only proxies you run or trust. The chat believes the visitor address they send.

Leave it out when visitors reach your web server directly.

02 · Pass the visitor’s host name on

The chat answers only questions sent from pages of its own site, so it compares the host name it receives with the one in the visitor’s browser. The proxy must keep it:

  • nginx: proxy_set_header Host $host;
  • Apache: ProxyPreserveHost On

Otherwise every question is refused with This chat answers only on its own site., and with the captcha on, solved captchas count as solved for another site.

03 · Let the answer through as it comes
  • /opensolr-chat/chat: no buffering, no compression, no caching. It is a stream, written word by word.
  • /opensolr-chat/admin and /opensolr-chat/config: no caching.

nginx as a reverse proxy in front of another web server:

location /opensolr-chat/ {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $host;
    proxy_buffering off;
    gzip off;
}

For a CDN or a load balancer, look in its documentation for streamed responses or Server-Sent Events. More on Streaming through your server.

Install on your server

The Opensolr Chat Bot Client is open source and MIT licensed. Questions about your Opensolr account, index or plan go to opensolr.com/contact; questions about the client itself belong on GitHub.

Opensolr Chat Bot Documentation