I'm trying to install my angular app under apache2 https server in ubuntu os.
I followed this link https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-18-04 to enable https under apache2. So apache2 https sites are configured in /etc/apache2/sites-available/default-ssl.conf like that:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName https://my_ip/
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
After restarting apache2 I was able to access to my app through https and navigate easily to all pages, but the only one thing that doesn't work fine is the rtsp live streaming.
My application is similar to what I described in this question: Not able to Show live camera RTSP streaming with Angular
So live streaming is shown in my angular app using JSMPEG library through an rtsp proxy like that:
new JSMpeg.Player('ws://my_ip:9999', {
canvas: this.streamingcanvas.nativeElement, autoplay: true, audio: false, loop: true
})
My angular app works fine if execute it with npm start. But under the https server the streaming is not displayed!!
After thinking I guess that may be there's something related to websockets that should be configured in my apache2 server. After searching I found this link: https://www.serverlab.ca/tutorials/linux/web-servers-linux/how-to-reverse-proxy-websockets-with-apache-2-4/
So I enabled ws in apache2 with a2enmod commands and I added those lines:
RewriteEngine on
RewriteCond ${HTTP:Upgrade} websocket [NC]
RewriteCond ${HTTP:Connection} upgrade [NC]
RewriteRule .* "wss://my_ip:9999/$1" [P,L]
ProxyPass / https://my_ip:9999/
ProxyPassReverse / https://my_ip:9999/
ProxyRequests off
to /etc/apache2/sites-available/default-ssl.conf file under VirtualHost tag. But this doesn't solve the problem.
Is there any suggestion to solve this problem ?