2

We want to use Apache2 as reverse proxy like Nginx in front of Ant Media Server. Even if http/s connections are succesfull, websocket connection cannot be established and we cannot publish webrtc live stream to Ant Media Server. What do you recommend to make it work?

Usama
  • 131

1 Answers1

1

here are the instruction for how to use Apache as reverse proxy.

  1. Enable the modules:
a2enmod proxy proxy_http proxy_wstunnel
  1. Edit /etc/apache2/sites-enabled/ams.conf file
<VirtualHost *:443>
    ServerName yourdomain.com
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/yourdomain.crt
    SSLCertificateKeyFile /etc/apache2/ssl/server.key
    SSLCertificateChainFile /etc/apache2/ssl/yourchain.crt
    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://localhost:5080/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*)           http://localhost:5080/$1 [P,L]
    ProxyPass / http://localhost:5080/
    ProxyPassReverse / http://localhost:5080/
</VirtualHost>
  1. And restart the apache2 service:
systemctl restart apache2
Usama
  • 131