Websocket connection fails with apache2


I am trying to deploy an app with apache2.

If “ip” is my ip, here is the config :

Apache 2 :

<VirtualHost *:80>
   ServerName ip

   RewriteEngine On

   RewriteCond %{HTTP:Upgrade} =websocket
   RewriteRule /twitter/(.*) ws://localhost:8501/$1 [P]
   RewriteCond %{HTTP:Upgrade} !=websocket
   RewriteRule /twitter/(.*) http://localhost:8501 [P]

   ProxyPassReverse /twitter/ http://localhost:8501

I launch with this command :
streamlit run index.py --server.enableCORS=false --server.enableXsrfProtection=false

But I still have :
WebSocket connection to ws:ip/twitter/stream failed

Thank’s for the help !