Streamlit with Apache reverse proxy - "Please wait..."

Hi all,

Setup:

Streamlit 1.4.0 deployed as a docker container, listening on port 8051, on an ec2 instance. Apache 2.4.18, on another node, is a reverse proxy to the streamlit app. Apache’s proxy, proxy_http and proxy_wstunnel modules are enabled.

Errors:

  1. “Please wait…” - message on the browser when the proxy URL is hit. The app loads fine when it’s accessed directly via http://<ec2_host_fqdn>:8051 though.

  2. Firing the proxy URL ‘https://streamlit-weekly.proxy.app.info’ (internal domain), on chrome’s debug console:

    WebSocket connection to 'wss://streamlit-weekly.proxy.app.info/stream' failed: WebSocket is closed before the connection is established.

    Uncaught Error: Unsupported state transition.
    State: PINGING_SERVER
    Event: CONNECTION_TIMED_OUT
     at Po.stepFsm (main.cb6e038a.chunk.js:2:491430)
     at main.cb6e038a.chunk.js:2:494477
    

Apache vhost:

<VirtualHost *:443>
    ServerName streamlit-weekly.proxy.app.info

  ## Vhost docroot
  DocumentRoot "/var/www/html"

  ## Directories, there should at least be a declaration for /var/www/html

  <Directory "/var/www/html">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
  </Directory>

  ## Logging
  ErrorLog "/var/log/apache2/streamlit-weekly.proxy.app.info_error_ssl.log"
  ServerSignature Off
  CustomLog "/var/log/apache2/streamlit-weekly.proxy.app.info_access_ssl.log" combined 

  ## Proxy rules
  ProxyRequests Off
  ProxyPass / http://streamlit01.app.us-west-2.private:8501/
  ProxyPassReverse / http://streamlit01.app.us-west-2.private:8501/

   <Location "/stream">
      ProxyPass wss://streamlit01.app.us-west-2.private:8501/stream
      ProxyPassReverse wss://streamlit01.app.us-west-2.private:8501/stream
   </Location>

  ## SSL directives
  SSLEngine on
  SSLCertificateFile      "/etc/ssl/certs/ssl-cert-snakeoil.pem"
  SSLCertificateKeyFile   "/etc/ssl/private/ssl-cert-snakeoil.key"
  SSLCACertificatePath    "/etc/ssl/certs"
  SSLProxyEngine On
</VirtualHost>

I referred quite a number of posts but I wasn’t able to find anything specific to Apache’s reverse proxy settings. Any help will be appreciated.

Thanks.

3 Likes

I am having a similar issue. I created a streamlit app and dockerized it. Now trying to reverse proxy my Apache server to connect to this docker container. But, the browser shows “Please Wait” and on inspecting the web page, the console shows the “Websocket connection failed”.
I am not well versed in how to upgrade the connection to websockets from my Apache SSL config.
Also, I am reverse proxying the docker IP to a subfolder rather than using the “/”. Like HTTP://my_server_name/my_awesome_app/

If you found a solution then please share.