如果將FreeSWITCH用於雲端, 支持大規模並發呼叫, 就要用到 多域/多租戶 技術了, FreeSWITCH 本身可以直接支持.
每個域可以單獨, 擁有相同的分機號也互相打不通, 各自線路, IVR , 路由等不相同.
配置方式如下:
1. conf/vars.xml
<X-PRE-PROCESS cmd="set" data="domain=$${local_ip_v4}" /> <X-PRE-PROCESS cmd="set" data="domain_name=$${domain}" />
這里配置了 默認 domain(名字), 啟用域(多租戶)之后就沒什么用啦.
2. conf/sip_profile/internal.xml
<!--all inbound reg will look in this domain for the users --> <param name="force-register-domain" value="$${domain}"/> <!--force the domain in subscriptions to this value --> <param name="force-subscription-domain" value="$${domain}"/> <!--all inbound reg will stored in the db using this domain --> <param name="force-register-db-domain" value="$${domain}"/>
三個 強制參數, 注釋掉, 重啟該 profile.
<可以建立多個 profile>
3. conf/directory/default.xml
<include> <!--the domain or ip (the right hand side of the @ in the addr--> <domain name="$${domain}">
這個 domain 指定了 此用戶目錄配置適用於哪個 domain(名字) (默認$${domain}是vars.xml中配置的)
可以建立多個 domain 的配置(如 復制多份,每份各自配置domain_name),
這樣 就有了多個域了(name 配置成指定的 domain_name)
多個域,最好每個域都有各自的用戶目錄及用戶配置(主要是有各自的用戶配置)
相應的,用戶配置的加載也要改:
<users> <X-PRE-PROCESS cmd="include" data="default/*.xml"/> </users>
<另,要讓各自域中的用戶使用(各自)單獨的 Dialplan 進行路由,還要改用戶配置中的 user_context 參數>
4. conf/directory/default/<user>.xml
要讓各自域中的用戶使用(各自)單獨的 Dialplan 進行路由,還要改用戶配置中的 user_context 參數
<variables> <variable name="user_context" value="default"/>
<這時候,就要相應的 增加 路由了, 否則沒有路由, 也是打不通的>
5. conf/dialplan/default.xml
<include> <context name="default">
復制這個dialplan,並更改 context_name , 與用戶配置中設置的相對應
6. reloadxml, 注冊,撥打測試
7. 啟用域之后, 撥打就不能在使用了 `user/1000` 這樣的縮寫形式了,
必須使用完整形式: `user/1000@${domain_name}`
在使用 會議, fifo 等應用時,也要寫完整形式,
即: 啟用域(多租戶)之后,撥打用戶就要寫完整(帶域名)的了,不然就找不到用戶了
8. 還可以將不同的域(租戶)分到不同的 Sofia Profile 中,可以使不同的 profile 使用不同的端口了
使用端口注意:
不同的profile 要額外注意 ws 的端口, 否則可能 造成 profile啟動失敗, 但是 莫名其妙的不知道 為嘛失敗(sip端口沒有占用啊.呵呵)
<!-- for sip over websocket support --> <param name="ws-binding" value=":5066"/> <!-- for sip over secure websocket support --> <!-- You need wss.pem in $${certs_dir} for wss or one will be created for you --> <param name="wss-binding" value=":7443"/>