2016-11-21 79 views
0

我正在嘗試使用WebRTC在兩個設備(瀏覽器)之間傳輸文件。我跟着這個GitHub repo來設置signalmaster信令服務器,它工作正常。所以,我把一個簡單的index.html頁面放在同一個文件夾中。但是當我轉到http://localhost:8888時,它不顯示頁面。然後我發現Signaling服務器不是一個Web服務器。所以,我使用Web server for chrome設置了一個網絡服務器。WebRTC:我怎樣才能一起安裝signling-server和webserver?

在這一點上我感到困惑:

  1. ,同時具有一個Web服務器需要信令服務器!和
  2. 如果我無法加載網頁,我將如何使用信令服務器!

很簡單,爲什麼我需要信令服務器,如果我已經不使用它?!另外,我如何設置一個signling-server和webserver在一起,以便我的頁面可以加載!

回答

1

有可能與的NodeJS,PHP和使用nginx當前網頁的組合。 Nodejs和信令服務器在端口8888的後臺運行,並且通過反向代理,您可以在網址中沒有端口的情況下調用網頁。

server { 
    listen 80 default; 

    server_name http://192.168.229.128; 


    root /var/www/html; 

    index index.php index.html index.htm index.nginx-debian.html; 

    location/{ 
      proxy_pass http://localhost:8888; 
      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; 
    } 


    location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
} 



    location ~* \.io { 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_set_header X-NginX-Proxy true; 

    proxy_pass http://localhost:8888; 
    proxy_redirect off; 

    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    } 



} 

在這種情況下,使用了socket.io,但如果需要,可以將其刪除。