Running multiple chatbots on same server and hiding ports

I suggest you read more about nginx.

You’ll need a config file for nginx, you can use something similar to the following:

server {
	listen 443 default_server;
	server_name mydomain.com;
	ssl on;
	ssl_certificate /path/to/certificate;
	ssl_certificate_key /path/to/certificate/key;
	ssl_session_cache shared:SSL:10m;

	location /chatbot1/ {
		proxy_pass http://localhost:5001/;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;                                                      
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
	}

	location /chatbot2/ {
		proxy_pass http://localhost:5002/;
		proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
	}

}

server {
	listen 80 default_server;
	server_name mydomain.com;
	return 301 https://$host$request_uri;
}

Note: I see that you want to use the socketio channel, hence the config of nginx above has been modified to upgrade the http connections to websocket connection.

1 Like