Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions
You are not logged in.
Pages: 1
Hi all,
I'm trying to setup LiveHelperChat behind NGINX with the Node.js (websocket) part on the same domain as the main PHP LiveHelperChat application. The primary reason for doing this is easy maintenance by keeping the whole thing on a single domain. The normal PHP LiveHelperChat application works but I'm having trouble with the Node.js part. Somehow the client does not seem satisfied; It opens a connection to the right URL (for example 'https://livechat.foo.bar/ws/?EIO=3&tran … 81900-4237') but on the server side it shows the client immediately closes the connection (and immediately retries) after it has received a HTTP 200 OK from the node.js application.
Relevant NGINX config; The PHP application is hosted on '/' and the websockets are accessible under '/ws'. EDIT: I should probably clarify that the 'backendserver' server runs an NGINX instance with PHP and PHP-FPM, hence that's why the '/' location is so 'simple'. But it also hosts the node.js application on which this frontend NGINX connects directly.
server {
listen 192.168.3.165:443;
server_name livechat.foo.bar;
ssl on;
ssl_certificate /etc/pki/tls/certs/livechat_foo_bar.crt;
ssl_certificate_key /etc/pki/tls/private/livechat_foo_bar.key;
ssl_trusted_certificate /etc/pki/tls/certs/startssl/foobar-bundle.pem;
add_header Strict-Transport-Security max-age=15768000;
location / {
proxy_pass https://backendserver;
proxy_buffering off;
proxy_read_timeout 3600;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /ws/ {
proxy_pass http://backendserver:31129;
proxy_redirect off;
proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
}
Node.js server 'settings.js':
var settings = {}
// Enable push notifications. Requires Redis.
settings.use_publish_notifications = true;
// If the desktop client isn't used we can save some resources.
settings.ignore_desktop_client = true;
settings.redis = {};
settings.redis.port = 6379;
settings.redis.host = 'localhost';
settings.redis.options = {};
settings.web = {};
settings.debug = {};
settings.socketiopath = '/opt/livehelperchat-246/lhc_web/node_modules/socket.io';
settings.web.host = "backendserver";
settings.web.port = 31129;
settings.debug.output = true;
module.exports = settings;
'nodejshelper_config.tpl.php':
<?php
$nodeJsHelperSettings = array (
'prefix' => 'https://',
'host' => 'livechat.foo.bar',
'port' => ':443',
'path' => '/ws',
// TLS part is handled by NGINX.
'secure' => false,
// Should we use google provided socket.io.js library?, if you are using older version set it to false
'use_cdn' => false,
// Load socket.io.js file from local filesystem. If use_cdn and use_local_socket_io_js will be false, system will try to load socket.io.js file from node server
'use_local_socket_io_js' => true,
'use_publish_notifications' => true,
'redis' => array (
'scheme' => 'tcp',
'host' => 'localhost',
'port' => 6379,
),
'instance_id' => 0, // Set erLhcoreClassInstance::getInstance()->id for automated hosting extension support
);
?>
Last edited by jasper (2016-07-04 13:17:45)
Offline
Right I figured it out. I failed to realize that Nodejs's socket.io uses a fixed path of '/socket.io'. So the solution is to change 'location /ws' to 'location /socket.io' in NGINX'es config.
Offline
Thank you for the feedback, happy to read you have fixed also thanks for share the solution.
PeopleInside - Live helper chat - free limited forum support!
For commercial support or GitHub [see FAQ here]
If you want to support this open source project, just donate [see support page]
Something wrong with the forum? [contact a superhero]
Offline
Pages: 1