Back

Realtime don't work with domain name

  • 1
  • Self Hosted
  • Realtime
SpencerSama
14 Nov, 2023, 21:47

I've just noticed that when I use my IP address with the port where Appwrite is installed on my server, they all work very well. But when I use the reverse proxy domain name linked to the ip address mentioned above, the problem starts all over again.

TL;DR
The user is experiencing an error with realtime not working with a domain name. They have tried various suggestions, including modifying the Apache config and using different IP addresses and ports. However, the problem persists. They have noticed that when they use the IP address directly, it works fine, but when using the reverse proxy domain name, the problem occurs again. Solution: It is recommended to ensure that the alias and server IP are correct and to use the correct IP address and port for the Appwrite instance. Additionally, adding the line `RewriteCond %{HTTP:Connection} upgrade [NC]` and modifying the Apache config accordingly may help resolve
Drake
14 Nov, 2023, 21:48

This locale problem is different. Let's keep that conversation on that other thread

fafa
14 Nov, 2023, 21:49

You need something like this if you use apache:

TypeScript
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteRule /(.*) ws://127.0.0.1:8000/$1 [P,L]
fafa
14 Nov, 2023, 21:49

change the IP and Port based on what you have

SpencerSama
14 Nov, 2023, 21:51

okay

SpencerSama
14 Nov, 2023, 21:51

Let me try

SpencerSama
14 Nov, 2023, 22:07

I have same error πŸ˜…

Drake
14 Nov, 2023, 22:24
  1. What did you add exactly?
  2. What ports are being used by your appwrite instance?
  3. Perhaps you also need RewriteCond %{HTTP:Connection} upgrade [NC]
SpencerSama
14 Nov, 2023, 22:29

1 .... `<VirtualHost *:80> ServerName mboasms.cm ServerAlias www.mboasms.cm

TypeScript
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full

<Proxy *>
    Require all granted
</Proxy>

ProxyPass / http://localhost:89/
ProxyPassReverse / http://localhost:89/
RewriteEngine on
RewriteCond %{SERVER_NAME} =mboasms.cm [OR]
RewriteCond %{SERVER_NAME} =www.mboasms.cm
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://78.46.11.35:89/$1 [P,L]

</VirtualHost>`

SpencerSama
14 Nov, 2023, 22:30
  1. port 89 for http and 90 for https
D5
14 Nov, 2023, 22:42

Are you sure alias is correct? Also did you have tried instead of localhost, setting the server IP?

SpencerSama
14 Nov, 2023, 22:51

When a i use Ip i have error.

SpencerSama
14 Nov, 2023, 22:52

`<VirtualHost *:80> ServerName mboasms.cm ServerAlias www.mboasms.cm

TypeScript
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full

<Proxy *>
    Require all granted
</Proxy>

ProxyPass / http://78.46.11.35:89/
ProxyPassReverse / http://78.46.11.35:89/
RewriteEngine on
RewriteCond %{SERVER_NAME} =mboasms.cm [OR]
RewriteCond %{SERVER_NAME} =www.mboasms.cm
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule /(.*) ws://78.46.11.35:89/$1 [P,L]

</VirtualHost>`

Drake
14 Nov, 2023, 22:55

make sure you use 3 backticks for multi line code

Drake
14 Nov, 2023, 22:56

is apache on the same server as Appwrite?

SpencerSama
14 Nov, 2023, 22:59

Yes

Drake
14 Nov, 2023, 23:05

I would suggest proxying to HTTPS and localhost and also enabling firewall to block port 89 and 90

Drake
14 Nov, 2023, 23:09

so maybe something like:

TypeScript
<VirtualHost *:80>
    ServerName mboasms.cm
    ServerAlias www.mboasms.cm

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full

    <Proxy *>
        Require all granted
    </Proxy>

    ProxyPass / http://locaol:89/
    ProxyPassReverse / http://localhost:89/
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =mboasms.cm [OR]
    RewriteCond %{SERVER_NAME} =www.mboasms.cm
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule /(.*) ws://localhost:89/$1 [P,L]
</VirtualHost>
Drake
14 Nov, 2023, 23:09

but also this is only the port 80 apache config. you need the port 443 one too

SpencerSama
14 Nov, 2023, 23:31

I have applied your suggestions but the problem persists. πŸ˜… 😭

Drake
15 Nov, 2023, 00:17

What's your 443 apache config?

SpencerSama
15 Nov, 2023, 00:21

`<VirtualHost *:443> ServerName mboasms.cm ServerAlias www.mboasms.cm

TypeScript
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full

<Proxy *>
    Require all granted
</Proxy>

ProxyPass / https://localhost:90/
ProxyPassReverse / https://localhost:90/
RewriteEngine on
RewriteCond %{SERVER_NAME} =mboasms.cm [OR]
RewriteCond %{SERVER_NAME} =www.mboasms.cm
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule /(.*) wss://localhost:90/$1 [P,L]

</VirtualHost>`

Drake
15 Nov, 2023, 01:02

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

Drake
15 Nov, 2023, 01:03

So what's the error now?

SpencerSama
15 Nov, 2023, 01:18

The same error when i remove client.setSelfSigned()

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more