I want to do that so I can run multiple chatbots on the same VM and I dont expose the ports. After doing this the idea is to insert the chatbot on a 3rd user web like this:
You can achieve this with nginx. nginx will listen for requests coming at port 443 (HTTPS) and will act as a reverse proxy to forward the requests coming at these locations to the appropriate server.
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.
You are welcome. I see that you have declared your server in nginx.conf file. I think the correct way to do this is to create a seperate conf file inside the sites-available directory and create a symbolic link to it in the sites-enabled directory. Atleast that’s how I did it back then
In your /etc/nginx/sites-available/default add the code that @saurabh-m523 put above ( make sure that you have a symbolic link to this file in /etc/nginx/sites-enabled/)
hello @saurabh-m523 i have the same problem could you please help me solve this ? i am using docker-compose installation i have wo separate folder for each bot and two docker instance.
both of them need to be accessible via https but i dont know how to make the configuration’s file
This is how I made it.
I have multiple Rasa bots running in Ubuntu 18.04 cloud server. I use docker-compose to run them. For chatbot frontend I use Botfront webchat. Chatbot webpage is running in Apache2 webserver. And finally I have Nginx configured as HTTPS Reverse proxy. So it hides all port numbers and subdomains and also enables that behind it you can use HTTP. So here are my configuration files, hope they help
in this location
paulii@vetbot7:/etc/nginx/sites-available$
I have Nginx configuration file
server {
server_name testibot1.omnia.fi;
index index.php index.html index.htm index.nginx-debian.html;
root /var/www/public_html/testibot1;
location / {
proxy_pass http://testibot1.omnia.fi:444;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
location /socket.io/ {
proxy_pass http://testibot1.omnia.fi:5006/socket.io/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
access_log /var/log/nginx/testibot1.fi_access.log;
error_log /var/log/nginx/testibot1.fi_error.log;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/testibot1.omnia.fi/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/testibot1.omnia.fi/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
server_name testibotti2.omnia.fi;
index index.php index.html index.htm index.nginx-debian.html;
root /var/www/public_html/testibotti2;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://testibotti2.omnia.fi:444;
}
location /socket.io/ {
proxy_pass http://testibotti2.omnia.fi:5007/socket.io/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
access_log /var/log/nginx/testibotti2.fi_access.log;
error_log /var/log/nginx/testibotti2.fi_error.log;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/testibot1.omnia.fi/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/testibot1.omnia.fi/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = testibot1.omnia.fi) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name testibot1.omnia.fi;
return 404; # managed by Certbot
}
server {
if ($host = testibotti2.omnia.fi) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name testibotti2.omnia.fi;
return 404; # managed by Certbot
}
and then my index file
in this location
paulii@vetbot7:/var/www/public_html/testibot1$
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://cdn.jsdelivr.net/npm/rasa-webchat@0.11.12/lib/index.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
Testisaitti 1
<div id="webchat"></div>
<script>
WebChat.default.init({
showFullScreenButton: true,
selector: "#webchat",
initPayload: "/tervetuloa",
customData: {"language": "fi"}, // arbitrary custom data. Stay minimal as this will be added to the socket
//socketUrl: "http://testibot1.omnia.fi:5006",
socketUrl: "https://testibot1.omnia.fi",
socketPath: "/socket.io/",
embedded: false,
title: "AsPa botti",
subtitle: "Testibotti 1",
inputTextFieldHint: "Vastaa kysymyksiin",
profileAvatar:"robot_icon.png",
params: {"storage": "session"} // can be set to "local" or "session". details in storage section.
})
</script>
</body>
</html>
hello @InnoOmnia thanks for your reply and sorry for the late reply
so you generated two certificates with certbot ? how did you manage the ssl on differents ports ?
When use Certbot to create certificates it asks for what domain addresses you want to create certificates. Then Certbot add automatically all config files etc.