diff --git a/.env.example b/.env.example index 53d48bf3..5ed17216 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,10 @@ APP_NAME=Laravel APP_ENV=local APP_KEY= APP_DEBUG=true -APP_URL=http://localhost +APP_URL=http://testcall.shupian.cn +FS_HOST=192.168.254.216 +FS_WSS_URL=testcall.shupian.cn +WEBSOCKET_URL=testcall.shupian.cn LOG_CHANNEL=stack diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 454cb176..550959c1 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -24,6 +24,7 @@ class IndexController extends Controller 'host' => config('freeswitch.host'), 'uri' => $user->sip->username . '@' . config('freeswitch.host'), 'wss_url' => config('freeswitch.wss_url'), + 'websocket_url' => config('freeswitch.websocket_url'), ]; return View::make("layout", compact('data')); } diff --git a/config/freeswitch.php b/config/freeswitch.php index c7f70c12..2aa42d8a 100644 --- a/config/freeswitch.php +++ b/config/freeswitch.php @@ -44,8 +44,9 @@ return [ 'api' => 'api_exec_queue', ], 'record_url' => env('APP_URL','http://localhost'), - 'host' => '192.168.254.216', - 'wss_url' => 'testcall.shupian.cn', + 'host' => env('FS_HOST','127.0.0.1'), + 'wss_url' => env('FS_WSS_URL','127.0.0.1'), + 'websocket_url' => env('WEBSOCKET_URL','127.0.0.1'), 'node_type' => [ 1 => '公共节点', diff --git a/public/service/rewrite.conf b/public/service/rewrite.conf new file mode 100644 index 00000000..e06565b7 --- /dev/null +++ b/public/service/rewrite.conf @@ -0,0 +1,15 @@ +location / { + try_files $uri $uri/ /index.php$is_args$query_string; + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; +} +location /wss { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:9502;#代理到上面的地址去 +} diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php index 70060a43..7a8466dd 100644 --- a/resources/views/layout.blade.php +++ b/resources/views/layout.blade.php @@ -330,7 +330,6 @@ userAgent.start() } - $("#regBtn").click(function () { initUserAgent(); userAgent.register(); @@ -340,9 +339,9 @@ userAgent.unregister() } }) + @endif - - const ws = new WebSocket("ws://127.0.0.1:9502?user_id={{auth()->user()->id}}") + const ws = new WebSocket("wss://{{$data['websocket_url']}}/wss?user_id={{auth()->user()->id}}") var ticker ws.onopen = function () { ticker = setInterval(function () { @@ -371,7 +370,7 @@ clearInterval(ticker) } } - @endif + });