Streamlit app stuck on „Please wait…“ on VPS with Apache2 - web

I’m trying to deploy my app and all was great but I’m getting constant “Please wait…”.
Here is what I’m getting in browser console:
WebSocket connection to ws://<URL> failed: WebSocket is closed before the connection is established.
WebSocket connection to ws://<URL> failed: WebSocket is closed before the connection is established.
Uncaught Error: Unsupported state transition.
State: PINGING_SERVER
Event: CONNECTION_TIMED_OUT
at e.value (main.a8683c40.chunk.js:2:120961)
at main.a8683c40.chunk.js:2:123059
Here is my app.domain.com.conf of apache2:
<VirtualHost *:80>
ServerAdmin admin#domain.com
ServerName app.domain.com
ServerAlias app.domain.com
ProxyRequests Off
<Location />
ProxyPass http://app.domain.com:8502/
ProxyPassReverse http://app.domain.com:8502/
ProxyPreserveHost On
</Location>
# Uncomment the line below if your site uses SSL.
#SSLProxyEngine On
</VirtualHost>
Here is my ports.conf
Listen 80
Listen 8501
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
On my main domain I’m hosting the landing page (port 80) and on app.mydomain.com (port 8502) streamlit app
What could be the issue here? Thank you!
I think tried everything what is online like:
Running these things:
streamlit run my_app.py --server.enableCORS=false
streamlit run my_app.py --server.enableWebsocketCompression=false
Adding this to streamlit config:
serverPort = 8502
Changing mydomain.com to server_ip also didn’t help
and all other things found online also were tried.

Related

How do I redirect all calls on one port to the same URL on another port with apache?

I'm hosting a sails.js application on the default port 1337. I have an apache serving as its proxy on port 8080:
[root#ip-192-168-0-XX conf.d]# cat nodetest.conf
Listen 8080
<VirtualHost 192.168.0.XX:8080>
Options -Indexes
ProxyRequests on
ProxyPass / http://localhost:1337/
</VirtualHost>
The Sails application has an API. So for instance, if I want to post a message, I enter this into my browser:
http://localhost:1337/Message/postMessage
I want that to happen when I enter the same address on port 8080.
http://localhost:8080/Message/postMessage
I am brand new to this Apache stuff, so I don't even know what the thing I want to do right now is called? Reverse Proxy? Regular Proxy? Redirects? I just don't know.
Firstly, I guess you would really only need to do this if you have Apache hosting other sites on the same server.
If you have no intention of running other sites on the same server with Apache, you can always just hit the Sails server directly at port 80 or 8080 by changing the port in your sails application in the config/local.js file.
Change
// port: process.env.PORT || 1337,
To
port: process.env.PORT || 80,
For other applications, like load balancing or basic proxying, I think nginx would be a far better solution.
The standard configuration for using Apache as a proxy for Sails would be something like this:
<VirtualHost *:8080>
ServerName example.com
ServerAlias www.example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:1337/
ProxyPassReverse http://localhost:1337/
</Location>
</VirtualHost>

Apache reverse proxy configuration issue

i have a problem with setting up an apache reverse proxy server and hope you can help.
I have 3 ubuntu web servers, available on https://service1.domain.com, https://service2.domain.com:4433 and so on...
Now, i will access these servers without typing the port in the addressbar.
So my idea is to use an reverse proxy server, that i can type in service2.domain.com and it redirects to service2 (https).
I installed an ubuntu server with apache and enabled the modules:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
Then i set up the 000-default.conf on the proxy with the following content:
<VirtualHost service1.domain.com:80>
ProxyPreserveHost On
ProxyPass / https://service1.domain.com/
ProxyPassReverse / https://service1.domain.com/
</VirtualHost>
<VirtualHost service2.domain.com:80>
ProxyPreserveHost On
ProxyPass / https://service2.domain.com/
ProxyPassReverse / https://service2.domain.com/
</VirtualHost>
The ports 80 and 443 on the router are forwarded to the proxy server.
On the service(1-3) servers, SSL is enabled with certificates from Lets Encrypt.
Now, if i try to open site service1.domain.com, i get an error (cert_name).
The sites now should not be accessible directly, because there is no port forwarding anymore.
My question is now, how is the right config for reverse proxies? Do i need to enable a certificate for each service also on the proxy server?
Thank you for your help!
Not exactly sure what your end goal is. The certificate is for the client facing server. If you want people to hit the site without having to set the port, you can use the Redirect statement in the virtual host config.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://www.example.com
</VirtualHost>
Which would forward any non ssl traffic to use the ssl virtual host.

Exposing a webserver not listening on port 80

My question is probably trivial and a duplicate, but either I cannot formulate it or it's not been answered on SO yet.
I have two webservers on a Digital Ocean droplet. One is listening on port 80 and can be accessed via example.com (DNS are on route 53), and the other is on port 8080: how can I make it accessible from example-2.com?
I suppose the software I'm looking for would intercept the HTTP requests, check the referrer, and route those coming from example.com to port 80 and those coming from example-2.com to port 8080. What is it?
This can not be done using only DNS. By default web browsers attempt to connect to port 80 when the url starts with "http" without specifying a port. The user would have to know to connect to port 8080 and explicitly access the URL as
http://example-2.com:8080
I am assuming you are running both web server instances on the same OS environment/IP address, though this would also work for separate hosting environments. What you probably want is a reverse web proxy which can inspect the requested domain name and route to an appropriate server instance. You would run the reverse web proxy on port 80, and probably move the server you are currently running on port 80 to another port (say, 8081).
Apache with mod_proxy and the virtual hosting settings is a possible solution. Assuming example.com and example-2.com point to the Apache instance configure it something like this:
<VirtualHost *:80>
ServerName example.com
ServerAdmin webmaster#example.com
ProxyRequests off
ProxyPreserveHost on
ProxyPass / http://localhost:8081/
ProxyPassReverse / http://localhost:8081/
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>
<VirtualHost *:80>
ServerName example-2.com
ServerAdmin webmaster#example-2.com
ProxyRequests off
ProxyPreserveHost on
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>

Redirect my domain name to specific port

I currently have a website running under apache on my VPS, but i'm planning to run another website with NodeJS.
Since apache runs on port 80 and NodeJS on port 3000 i was wondering how i could manage that when someone type the domain name domain.com, it binds to the port 3000 ?
Also, is it possible that after the redirect on the browser it shows only http://domain.com and not http://domain.com:3000 ?
Use ProxyPass:
<VirtualHost *:80>
ServerName domain.com
ProxyRequests Off
ProxyPass / http://domain.com:3000/
ProxyPassReverse / http://domain.com:3000/
</VirtualHost>

CSS not loading when site is accessed over HTTPS using an Apache reverse proxy server

Thanks in advance for any help!
I'm running Ubuntu 13.1 on an EC2 instance. My app is written in Node.JS (based off NodeBB) and I'm using Apache 2 as a reverse proxy server to establish a secure connection on port 443.
The problem is that when I visit the website via HTTPS, none of the CSS is rendered!
My browser registers a number of errors of these 3 types:
Failed to load resource: the server responded with a status of 502 (Proxy Error)
Uncaught ReferenceError: require is not defined
Failed to load resource: net::ERR_CONNECTION_TIMED_OUT
Here's my config file:
<VirtualHost *:443>
ServerName forum.ligma.com
SSLEngine on
SSLCertificateFile /etc/apache2/forum_ligma_com.crt
SSLCertificateKeyFile /home/ubuntu/.ssh/myserver.key
SSLCACertificateFile /etc/apache2/combined-ca.crt
<IfModule mod_proxy.c>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</IfModule>
ProxyPass / http://127.0.0.1:4568
ProxyPassReverse / http://127.0.0.1:4568
</VirtualHost>
Any ideas what's going wrong? Thanks!

Resources