1. Your server (iptables firewall and cloud server security group or security policy) opens two ports firstly: 8430, 8431
Keep the Socket Service Port in the backend of WeLive:8430
8430 port: Used to connect client (browser)
8431 port: The PHP socket process of WeLive monitors and processes messages from 8430 port
2. Modify WeLive file ./includes/class.Websocket.php:
if(!socket_bind($this->socket, $this->host, $this->port)){ if(!socket_bind($this->socket, "0.0.0.0", $this->port)) return false; }
Saved As:
if(!socket_bind($this->socket, $this->host, "8431")){ if(!socket_bind($this->socket, "0.0.0.0", "8431")) return false; }
3. Modify server configuration:
i). Apache server, Add below codes at the end of SSL configuration file, such as: /usr/local/apache/conf/extra/httpd-ssl.conf
#listen 8430 port
Listen 8430
#Add Virtual Host
<VirtualHost _default_:8430>
#Modify according to your actual domain name
ServerName xxxx.com:8430
SSLEngine on
SSLProxyEngine on
#Modify according to the actual key filepath of your server
SSLCertificateFile "/usr/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
#Forwarding HTTPS of port 8430 to ws of port 8431
ProxyRequests off
ProxyPass / ws://localhost:8431
ProxyPassReverse / ws://localhost:8431
</VirtualHost>
ii). Nginx server, Modify the configuration file of Nginx, such as: /etc/nginx.conf
http {
...........
#add server
server{
listen 8430;
ssl on;
#Modify according to your actual domain name
server_name xxxxx.com;
#Modify according to the actual key filepath of your server
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
location / {
proxy_pass ws://localhost:8431;
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 $remote_addr;
}
}
...........
}
4. Reboot your server(reboot)