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.
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.
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 itsX-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.
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.
/opensolr-chat/chat: no buffering, no compression, no caching. It is a stream, written word by word./opensolr-chat/adminand/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
- Installing
- Mounting on Apache
- Mounting on nginx
- Behind a proxy
- Streaming