How to pass a variable(a jitsi web url) to the websocket line in config.js

Now we have a websocket line in config.js:

websocket: wss://${ location.hostname }/xmpp-websocket,

and it works for web calls. But for mobile apps(android/ios) it doesn’t work. I’ve set a hardcode value(jitsidev.mydomain.com) instead of ‘location.hostname’ and it worked with mobile app as well. But how can I put there a variable instead of direct value? I tried different variants like these:

  1. websocket: wss://${ FRONTEND_DOMAIN_NAME }/xmpp-websocket,
  2. websocket: ‘wss://${ FRONTEND_DOMAIN_NAME }/xmpp-websocket’- single quote is here instead of a tilde.
  3. websocket: wss://{{ FRONTEND_DOMAIN_NAME }}/xmpp-websocket
  4. websocket: wss://${ env.FRONTEND_DOMAIN_NAME }/xmpp-websocket

but I hadn’t success.

You can do that as the subdomain via ssi.

Thanks for answer!

But, I don’t know well with ssi.
What does it mean a subdomain in this line?

echo var=“subdomain” default=“”

Should I replace it with my jitsi domain - jitsidev.mydomain.com or should I leave it as it is?

This is server side include. You get the subdomain from the URL that hits nginx and set it as a variable and once config.js is ready to be served, those variables are replaced. You can do something similar in your nginx config for different domains.

Here how is prefix var set to empty string:

You can set your new var to your host and use it in the config.js

More info: Module ngx_http_ssi_module

Thank you, I’ll try it.

Well, I’ve tried this way, but I get an empty value for subdomain. I have ssi on and ‘set $subdomain “$1.”’ in meet.conf file.

meet.conf

ssi on with javascript for multidomain variables in config.js

ssi on;
ssi_types application/x-javascript application/javascript;

{{ if $ENABLE_XMPP_WEBSOCKET }}
# websockets for subdomains
location ~ ^/([^/?&:'"]+)/xmpp-websocket {
set $subdomain “$1.”;
set $subdir “$1/”;
set $prefix “$1”;

        rewrite ^/(.*)$ /xmpp-websocket;
    }
    {{ end }}

config.js

var subdomain = <!--# echo var="subdomain" default="" -->;

var config = {
// Connection
//

hosts: {
    // XMPP domain.
    domain: 'meet.jitsi',

    // When using authentication, domain for guest users.
    // anonymousdomain: 'guest.example.com',

    // Domain for authenticated users. Defaults to <domain>.
    // authdomain: 'jitsi-meet.example.com',

    // Focus component domain. Defaults to focus.<domain>.
    // focus: 'focus.jitsi-meet.example.com',

    // XMPP MUC domain. FIXME: use XEP-0030 to discover it.
    muc: 'muc.meet.jitsi'
},
// BOSH URL. FIXME: use XEP-0156 to discover it.
bosh: '/http-bind',
// Websocket URL
websocket: 'wss://' + subdomain + '/xmpp-websocket',

Thoughts?

Don’t touch existing ones, they already work. Subdomain is when you have Domain Registered at Safenames
.
Create a new one which is domain and is set with different value in your different nginx configs that handle different domains and use it in config.js so you will have same config.js for different domains.