I want to deploy my streamlit app at https://myweb.com/myapp based on Apache. First, I run my app on Server1 (10.0.0.xxx), which is my intranet, and the Apache configuration is
<VirtualHost *:80>
ServerName 10.0.0.xxx
ProxyPreserveHost On
ProxyPass /myapp http://localhost:8503
ProxyPassReverse /myapp http://localhost:8503
RedirectMatch 301 ^/myapp$ /myapp/
# WebSocket support
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/myapp/(.*) ws://localhost:8503/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule ^/myapp/(.*) http://localhost:8503/$1 [P,L]
</VirtualHost>
It can be successfully accessed at http://10.0.0.xxx/myapp/. And on my Server2, I used the similar configuration of Apache (expect from http://10.0.0.xxx/myapp
to https://myweb.com/myapp
)
<VirtualHost *:443>
ServerName myweb.com
ProxyPreserveHost On
ProxyPass /myapp http://10.0.0.xxx/myapp
ProxyPassReverse /myapp http://10.0.0.xxx/myapp
RedirectMatch 301 ^/myapp$ /myapp/
# WebSocket support
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/myapp/(.*) ws://10.0.0.xxx/myapp/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule ^/myapp/(.*) http://10.0.0.xxx/myapp/$1 [P,L]
</VirtualHost>
But it can not connect the WebSocket with the errorWebSocket connection to 'wss://myweb.com/myapp/_stcore/stream' failed:
I want to know where am I wrong, thanks!