Running multiple apps in a server hiding ports - apache

Im developing two different chatbots and I have them on a Google Platform VM. I want to know how to access to them like this:
-> https://example.com/chatbot1
-> https://example.com/chatbot2
Instead of having:
-> https://example.com:5001
-> https://example.com:5002
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:
<script>
WebChat.default.init({
selector: "#webchat",
initPayload: "XXX",
interval: 1000,
customData: {"userId": "123"},
socketUrl: "http://example.com/chatbot1",
socketPath: "/socket.io/",
title: "XXX",
subtitle: "XXX",
inputTextFieldHint: "XXX",
connectingText: "XXX",
hideWhenNotConnected: true,
fullScreenMode: false,
showFullScreenButton: false,
profileAvatar: "xxx.jpg",
params: {
images: {
dims: {
width: 250,
height: 200,
}
},
storage: "XXX",
},
})
</script>
Both need to run through HTTPS. Do I need Apache or something similar? If this is the case, how can I configure it? I dont know if it is relevant but I only have access to the VM through SSH.

It sounds like you might want to use Apache's name-based virtual hosts (see the example under Running different sites on different ports).

Related

Keystonejs 6 CMS allowing any origin even after adding CORS custom config

I am working on my blog and chose Keystonejs 6(CMS) to host my content. The issue is, CMS allows any origin and serve requests. This document says you can whitelist origin but seems like it is not working or I am not able to understand between the lines. My custom config looks like this:
keystone.ts:
const whitelist = ['https://example1.com', 'https://example2.com'];
export default withAuth(
config({
db,
storage: { ... },
lists,
session,
server: {
cors: {
origin: whitelist,
credentials: true,
},
port: Number(PORT) || 3000,
},
}),
);
Any help would be appreciated! Thanks for reading!

Simple peer different network calling Issue

I am using simple peer for my video call web application. when I call people in the same network video call is working perfectly. But in the different networks, it is not working. I also added ICE servers(stun/turn) to simple peer. Still, the same issue is happening can anyone please help me out. I am getting this issue in the console
Error: Connection failed. at h (index.js:17)at f.value (index.js:654) at RTCPeerConnection.t._pc.onconnectionstatechange (index.js:119)
const peer = new Peer({
initiator: true,
trickle: false,
stream,
config: {
iceServers: [
{
urls: "stun:numb.viagenie.ca",
username: "************",
credential: "************"
},
{
urls: "turn:numb.viagenie.ca",
username: "************",
credential: "************"
}
]
}
});
I had facing through the same issue.
I'm not sure if that has to do with those specific iceServers but I replace them with this ones on it works
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{ urls: 'stun:stun2.l.google.com:19302' },
{ urls: 'stun:stun3.l.google.com:19302' },
{ urls: 'stun:stun4.l.google.com:19302' },
{
url: 'turn:turn.bistri.com:80',
credential: 'homeo',
username: 'homeo',
},
{
url: 'turn:turn.anyfirewall.com:443?transport=tcp',
credential: 'webrtc',
username: 'webrtc',
},
Everything is working good but now my problem is that safari is not working just chrome with iOS
If someone knows how to handle this compatibility please contact me! :D
my issue here was with the stun/turn server.we can check the status of servers using
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
If you test a STUN server, it works if you can gather a candidate with type "srflx". If you test a TURN server, it works if you can gather a candidate with type "relay".
check you are getting this

For a TURN server that supports STUN, do I need to list both STUN and TURN urls in the client?

If I have a TURN server that can also act as a STUN, should my urls in my client looks like this?
myPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: "turn:example.org"
}
]
});
or like this?
myPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: "stun:example.org"
},
{
urls: "turn:example.org"
}
]
});
I only want the TURN functionality used if necessary, not for every connection.
Thanks!
You can write it like the second option. It will try to connect with the stun server and fallback to the turn server when the stun method doesn't work.

what is asterisk 13 configration for enabling WebRTC?

I want to setup asterisk 13 that working on ubuntu 16.04 on local machine to enable WebRTC, I'am testing with https://www.doubango.org/sipml5/ on firefox
I had the sipml5 client connected successfully to asterisk but when imitating a call it's said Call in Progress,
http is enable and bound to port 8088
this is sip.conf :
[web_rtc]
context=default
host=dynamic
secret=abc101
type=friend
transport=udp,ws,wss,tcp
encryption=yes
avpf=yes
force_avp=yes
icesupport=yes
directmedia=no
disallow=all
allow=opus
allow=ulaw
dtlsenable=yes
dtlsverify=fingerprint
dtlscertfile=/etc/asterisk/ast.pem
dtlscafile=/etc/asterisk/ast.pem
dtlssetup=actpass/
rtcp_mux=yes
and this is extension.conf :
[web_rtc]
exten => 100,1,Answer()
exten => n,Playback(hello-world)
exten => n,Hangup()
I have tested sipml5 on Ubuntu 18.04 on Asterisk 13 and it worked fine. I suggest to add to your rtp.conf file (/etc/asterisk/rtp.conf) an stun server by adding the following line:
stunaddr=stun.l.google.com:19302
Then, on the live demo, configure your ICE Servers on the expert mode section adding [{ url: 'stun:stun.l.google.com:19302'}]
Anyway, I tried sipml5 and I had some problems integrating it with Asterisk (I have problems muting the call or pausing it), so I tried other libraries and finally I decided to use sip.js (https://sipjs.com/), which I recommend.
Hope it helps.
I edit to add the sipml5 client stack configuration that I used on my JS script:
sipStack = new SIPml.Stack({
realm: 'example.com',
impi: 'sip_user',
impu: 'sip:sip_user#example.com:port',
password: 'super_secret_password',
websocket_proxy_url: 'wss://example.com:port/ws',
outbound_proxy_url: null,
ice_servers: "[{ url: 'stun:stun.l.google.com:19302'}]",
enable_rtcweb_breaker: true,
enable_early_ims: true,
enable_media_stream_cache: true,
sip_headers: [
{ name: 'enter code hereUser-Agent', value: 'IM-client/OMA1.0 sipML5-v1.2016.03.04' },
{ name: 'Organization', value: 'My_company' }
],
events_listener: { events: '*', listener: eventsListener }
});

How to ask to the service worker to ignore requests matching a specific URL pattern in Polymer?

My application is built on Polymer v2 and uses the Firebase Auth service for authentication. Actually, I use the login-fire element. For a better experience on mobile devices, I choose to sign-in with redirect.
In the "network" tab of the DevTool (in Chrome) I see that a request containing the /__/auth/handler? pattern is sent for requesting Google authentication (for example, if the provider used is Google).
With the service workers enabled, this request is caught and the response is the login page of my application. No login attempted, the response comes from the service worker and I get a Network Error from Firebase API because of a timeout.
When I deploy the app without service workers the authentication process is working and I can reach the app.
I tried many ways to config the service workers to ignore all requests to a URL with the /auth/ pattern but I failed.
See the last version of my config file bellow.
sw-precache-config.js
module.exports = {
globPatterns: ['**\/*.{html,js,css,ico}'],
staticFileGlobs: [
'bower_components/webcomponentsjs/webcomponents-loader.js',
'images/*',
'manifest.json',
],
clientsClaim: true,
skipWaiting: true,
navigateFallback: 'index.html',
runtimeCaching: [
{
urlPattern: /\/auth\//,
handler: 'networkOnly',
},
{
urlPattern: /\/bower_components\/webcomponentsjs\/.*.js/,
handler: 'fastest',
options: {
cache: {
name: 'webcomponentsjs-polyfills-cache',
},
},
},
{
urlPattern: /\/images\//,
handler: 'cacheFirst',
options: {
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
};
Do you have a better solution? Do you notice what I missed?
Thank you for your help.
You can add this to your sw-precache-config.js file
navigateFallbackWhitelist: [/^(?!\/auth\/)/],
You should only whitelist the paths of your application. This should be known to you.
So everything you do not whitelist, will not be served from the serviceworker.
navigateFallbackWhitelist: [/^\/news\//,/^\/msg\//, /^\/settings\//],
With this example, only news/*, msg/*,settings/* will be delivered.
/auth/*,/api/*,... will not be caught.