self-hosted icon indicating copy to clipboard operation
self-hosted copied to clipboard

A comprehensive guide to self host revolt

Open Midou36O opened this issue 2 years ago • 74 comments

Hello, i tried self hosting revolt through docker, sure enough the guide provided on readme worked. The problem is when creating an account on localhost i always get an error, furthermore, trying to proxying through nginx (using my own knowledge, which isn't really this advanced) made things worse as i didn't even knew what to proxy and what not. Would it be possible to write an actual complete guide to self host revolt? This defenitely would help people decentralize the service!

Midou36O avatar Dec 27 '21 16:12 Midou36O

I would love this as well. The current Docker setup does not work. Trying to create an account results in an unhelpful network error. Either the app needs to be fixed or the documentation needs to be updated.

yllekz avatar Jan 15 '22 15:01 yllekz

Unable to deploy it either. Stuck at nondescript "Network Error" when trying to log in remotely. Locally works just fine, however.

maxwelljens avatar Feb 04 '22 14:02 maxwelljens

@maxwelljens : You need to edit the .env config file. Otherwise it defaults to Screenshot from 2022-02-04 14-56-32

Which resolves to localhost. When you're using it locally, of course it resolves to localhost which is the server; outside of that network, though, would load to their localhost which the server is not hosted at. I'm not quite sure why it can't use relative URL's but it does mention that the default config only works for localhost in the readme

sigaloid avatar Feb 04 '22 19:02 sigaloid

@sigaloid Thanks for your reply.

I am aware of the .env file configuration. I changed every address accordingly, and port forwarded every relevant port. It doesn't work in spite of that.

maxwelljens avatar Feb 04 '22 20:02 maxwelljens

Try pressing F12 when logging in. That will let you see which network address it's going to. If it's still "local.revolt.chat:8000" then it's an issue with the config not being loaded correctly somehow. Otherwise it could be a bug in your web proxy

sigaloid avatar Feb 04 '22 20:02 sigaloid

Oops. I just tried deploying it and hit the same problem :p it seems my .env config is not being picked up in the docker-compose.

sigaloid avatar Feb 04 '22 20:02 sigaloid

@sigaloid Interesting. Good to know I am not the only one with this problem. Do let everyone know in this issue if you find a solution or workaround. Thanks.

maxwelljens avatar Feb 04 '22 20:02 maxwelljens

Okay so. Basic setup, just cloned the repo, edited .env to have different URL's for the API, but it still sends requests to http://local.revolt.chat:8000/auth/account/create. This seems to me like a problem with the environment variables because there's no configuration changes that are actually going through to the Delta server.

Basically, changing the API server in the .env has zero effect on the resulting containers. Did this on a fresh install. Looking like a bug in the docker compose setup to me at this point, maybe the env variables in the docker-compose.yml are not being properly retrieved?

Or maybe the ones in revoltchat/delta/docker-compose.yml supercede it... That would make sense because the ones there are the ones being used.

Anyway I am yet to find a solution. Unfortunately this is blocking me from deploying this awesome software ;(

sigaloid avatar Feb 04 '22 21:02 sigaloid

I just cloned the repo and am able to get a local version up and running just using docker compose up. I did have to adjust some of the port binding for my host machine due to conflicts but that was obvious in the logs. i.e. I changed 5000 to 42069 for the web app 5000:5000 became 42069:5000 and I can access Revolt using 127.0.0.1:42069 or local.revolt.chat:42069.

What do logs look like when you run docker compose up?

mirkoRainer avatar Feb 05 '22 02:02 mirkoRainer

For example, try changing REVOLT_APP_URL in the .env to some random domain and see if that's where the network requests go when you restart it. (Press F12 and try registering)

This is the scenario I had trouble with

sigaloid avatar Feb 05 '22 22:02 sigaloid

@sigaloid Thanks for your reply.

I am aware of the .env file configuration. I changed every address accordingly, and port forwarded every relevant port. It doesn't work in spite of that.

Same issue over here, nothing I do is working. Tried adding URLs in the docker-compose.yml environment but to no avail

Razorback360 avatar Feb 06 '22 13:02 Razorback360

https://asciinema.org/a/fqCutcwDYY2jK4mMcI6ewj1W8

Okay, so I re-pulled the docker container on my local PC rather than my VPS (sudo docker pull revoltchat/server:master) and did this to the .env file (even though it's gibberish). Oddly enough, when I attempted to register, it successfully sent it to the new domain I entered in the .env file. This means that I did succeed in making my config changes save.

I don't even know what I did differently (i did basically everything the same). And I still cannot make it work on the server.

I've been trying to fix this and running against a wall about this for days now. It's gotta be something really basic I'm overlooking.

sigaloid avatar Feb 06 '22 21:02 sigaloid

Starting from a fresh Docker install, my Fedora box can follow the directuions and persist config changes, but my Debian box cannot. Side by side, completely brand new environment... What OS are you on, @Razorback360 @mirkoRainer @maxwelljens ?

sigaloid avatar Feb 06 '22 21:02 sigaloid

@sigaloid My server is on Fedora 34.

maxwelljens avatar Feb 06 '22 22:02 maxwelljens

MacOS Apple Silicone

Get Outlook for iOShttps://aka.ms/o0ukef


From: maxwelljens @.> Sent: Sunday, February 6, 2022 5:00:19 PM To: revoltchat/self-hosted @.> Cc: Mirko Rainer @.>; Mention @.> Subject: Re: [revoltchat/self-hosted] A comprehensive guide to self host revolt (Issue #25)

@sigaloidhttps://github.com/sigaloid My server is on Fedora 34.

— Reply to this email directly, view it on GitHubhttps://github.com/revoltchat/self-hosted/issues/25#issuecomment-1030923198, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMTS6CBQWIJZU6JMPCP6HF3UZ3VPHANCNFSM5K2TFC4Q. You are receiving this because you were mentioned.Message ID: @.***>

mirkoRainer avatar Feb 06 '22 22:02 mirkoRainer

Starting from a fresh Docker install, my Fedora box can follow the directuions and persist config changes, but my Debian box cannot. Side by side, completely brand new environment... What OS are you on, @Razorback360 @mirkoRainer @maxwelljens ?

I'm on Ubuntu.

Razorback360 avatar Feb 07 '22 02:02 Razorback360

https://asciinema.org/a/fqCutcwDYY2jK4mMcI6ewj1W8

Okay, so I re-pulled the docker container on my local PC rather than my VPS (sudo docker pull revoltchat/server:master) and did this to the .env file (even though it's gibberish). Oddly enough, when I attempted to register, it successfully sent it to the new domain I entered in the .env file. This means that I did succeed in making my config changes save.

I don't even know what I did differently (i did basically everything the same). And I still cannot make it work on the server.

I've been trying to fix this and running against a wall about this for days now. It's gotta be something really basic I'm overlooking.

I think you need to refresh the cache. I tried to open the website in the browser's traceless mode, and the problem was successfully solved.

Ikun886-cxk avatar Feb 07 '22 03:02 Ikun886-cxk

Here is an example of nginx.

map $http_host $revolt_upstream {
  example.com http://127.0.0.1:5000;
  api.example.com http://127.0.0.1:8000;
  ws.example.com http://127.0.0.1:9000;
  autumn.example.com http://127.0.0.1:3000;
  january.example.com http://127.0.0.1:7000;
  vortex.example.com http://127.0.0.1:8080;
}

server {
  listen 80;
  listen 443 ssl http2;
  server_name example.com *.example.com;

  # SSL 

  if ($http_upgrade) {
    # Here, the path is used to reverse the generation of ws. Just roll the keyboard to prevent conflicts with other services.
    rewrite ^(.*)$ /ws_78dd759593f041bc970fd7eef8b0c4af$1;
  }

  location / {
    proxy_pass $revolt_upstream;
    proxy_set_header Host $host;
  }

  location /ws_78dd759593f041bc970fd7eef8b0c4af/ {
    # Note that here is the trailing slash.
    proxy_pass $revolt_upstream/;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Connection $http_connection;
    proxy_set_header Upgrade $http_upgrade;
    # Important, to prevent ws from sending data for a long time and causing timeout disconnection.
    proxy_read_timeout 24h;
  }
}

Ikun886-cxk avatar Feb 07 '22 03:02 Ikun886-cxk

asciinema.org/a/fqCutcwDYY2jK4mMcI6ewj1W8 Okay, so I re-pulled the docker container on my local PC rather than my VPS (sudo docker pull revoltchat/server:master) and did this to the .env file (even though it's gibberish). Oddly enough, when I attempted to register, it successfully sent it to the new domain I entered in the .env file. This means that I did succeed in making my config changes save. I don't even know what I did differently (i did basically everything the same). And I still cannot make it work on the server. I've been trying to fix this and running against a wall about this for days now. It's gotta be something really basic I'm overlooking.

I think you need to refresh the cache. I tried to open the website in the browser's traceless mode, and the problem was successfully solved.

Wow. My goodness. Is this some sort of caching issue? I disabled cache, refreshed, rebooted, etc and nothing fixed the issue. Are these resources aggressively cached?

Regardless, the fix is to NOT START THE DOCKER CONTAINER until you've set up the env file. I started the docker container to make sure the images were downloaded, then I stopped it to configure it. Thank you so much @SurpriseLon that saved me from a few more days of confusion!!

sigaloid avatar Feb 07 '22 12:02 sigaloid

Regardless, the fix is to NOT START THE DOCKER CONTAINER until you've set up the env file. I started the docker container to make sure the images were downloaded, then I stopped it to configure it. Thank you so much @SurpriseLon that saved me from a few more days of confusion!!

Solution mentioned here does not work for me. I have completely deleted the docker compose, removed all containers and their data, configured the .env, then deployed the compose and yet it is still the same issue. I am running on Ubuntu 20.04.3 LTS

Razorback360 avatar Feb 07 '22 13:02 Razorback360

A few things I can think of: Are you editing the .env.example? Make sure you cp .env.example .env and change the config in .env. Then, try in incognito mode or in a fresh browser - the javascript containing the server is heavily cached and the filename isn't dynamically changed based on its hash, so it will never re-request it. I even did F12 - disable cache and it didn't help. Only trying in incognito + Ctrl+F5'ing helped.

sigaloid avatar Feb 07 '22 13:02 sigaloid

Here is an example of nginx.

map $http_host $revolt_upstream {
  example.com http://127.0.0.1:5000;
  api.example.com http://127.0.0.1:8000;
  ws.example.com http://127.0.0.1:9000;
  autumn.example.com http://127.0.0.1:3000;
  january.example.com http://127.0.0.1:7000;
  vortex.example.com http://127.0.0.1:8080;
}

server {
  listen 80;
  listen 443 ssl http2;
  server_name example.com *.example.com;

  # SSL 

  if ($http_upgrade) {
    # Here, the path is used to reverse the generation of ws. Just roll the keyboard to prevent conflicts with other services.
    rewrite ^(.*)$ /ws_78dd759593f041bc970fd7eef8b0c4af$1;
  }

  location / {
    proxy_pass $revolt_upstream;
    proxy_set_header Host $host;
  }

  location /ws_78dd759593f041bc970fd7eef8b0c4af/ {
    # Note that here is the trailing slash.
    proxy_pass $revolt_upstream/;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Connection $http_connection;
    proxy_set_header Upgrade $http_upgrade;
    # Important, to prevent ws from sending data for a long time and causing timeout disconnection.
    proxy_read_timeout 24h;
  }
}

On this nginx config, would i need to make all those domains? As well as, can i not just reverse proxy those domains to the ports that they are on?

Alauraa avatar Feb 10 '22 13:02 Alauraa

Here is an example of nginx.

map $http_host $revolt_upstream {
  example.com http://127.0.0.1:5000;
  api.example.com http://127.0.0.1:8000;
  ws.example.com http://127.0.0.1:9000;
  autumn.example.com http://127.0.0.1:3000;
  january.example.com http://127.0.0.1:7000;
  vortex.example.com http://127.0.0.1:8080;
}

server {
  listen 80;
  listen 443 ssl http2;
  server_name example.com *.example.com;

  # SSL 

  if ($http_upgrade) {
    # Here, the path is used to reverse the generation of ws. Just roll the keyboard to prevent conflicts with other services.
    rewrite ^(.*)$ /ws_78dd759593f041bc970fd7eef8b0c4af$1;
  }

  location / {
    proxy_pass $revolt_upstream;
    proxy_set_header Host $host;
  }

  location /ws_78dd759593f041bc970fd7eef8b0c4af/ {
    # Note that here is the trailing slash.
    proxy_pass $revolt_upstream/;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Connection $http_connection;
    proxy_set_header Upgrade $http_upgrade;
    # Important, to prevent ws from sending data for a long time and causing timeout disconnection.
    proxy_read_timeout 24h;
  }
}

On this nginx config, would i need to make all those domains? As well as, can i not just reverse proxy those domains to the ports that they are on?

Yes,you can

Ikun886-cxk avatar Feb 11 '22 22:02 Ikun886-cxk

Here is an example of nginx.

map $http_host $revolt_upstream {
  example.com http://127.0.0.1:5000;
  api.example.com http://127.0.0.1:8000;
  ws.example.com http://127.0.0.1:9000;
  autumn.example.com http://127.0.0.1:3000;
  january.example.com http://127.0.0.1:7000;
  vortex.example.com http://127.0.0.1:8080;
}

server {
  listen 80;
  listen 443 ssl http2;
  server_name example.com *.example.com;

  # SSL 

  if ($http_upgrade) {
    # Here, the path is used to reverse the generation of ws. Just roll the keyboard to prevent conflicts with other services.
    rewrite ^(.*)$ /ws_78dd759593f041bc970fd7eef8b0c4af$1;
  }

  location / {
    proxy_pass $revolt_upstream;
    proxy_set_header Host $host;
  }

  location /ws_78dd759593f041bc970fd7eef8b0c4af/ {
    # Note that here is the trailing slash.
    proxy_pass $revolt_upstream/;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Connection $http_connection;
    proxy_set_header Upgrade $http_upgrade;
    # Important, to prevent ws from sending data for a long time and causing timeout disconnection.
    proxy_read_timeout 24h;
  }
}

On this nginx config, would i need to make all those domains? As well as, can i not just reverse proxy those domains to the ports that they are on?

Yes,you can

So this doesn't exactly answer my question, there was 2 in the sentence, just a yes doesn't help. Sorry for any confusion or etc.

Alauraa avatar Feb 14 '22 03:02 Alauraa

Hello everyone.

Sorry for the inactivity I had here (I had no pc). But I put HTTPS on my server. Problem, now it's giving me "network error". Could my other site (also in https) cause this problem?

Cocam123 avatar Feb 20 '22 08:02 Cocam123

Hello everyone.

Sorry for the inactivity I had here (I had no pc). But I put HTTPS on my server. Problem, now it's giving me "network error". Could my other site (also in https) cause this problem?

I'm also running into a myriad of issues when trying to convert a insecure instance of Revolt to https. I'm using the nginx config detailed in this same thread. Other than that, I've made no changes to my .env or docker-compose.yml beyond those that were required to get the insecure http-hosted version of my Revolt chat running. Any ideas? There seems to be an issue with an HTTP GET and a "Blocked loading mixed active content “http://[domain]:[port]/” error in the web dev console I cannot resolve.

whiskeytangofoxy avatar Mar 15 '22 02:03 whiskeytangofoxy

@maxwelljens : You need to edit the .env config file. Otherwise it defaults to Screenshot from 2022-02-04 14-56-32

Which resolves to localhost. When you're using it locally, of course it resolves to localhost which is the server; outside of that network, though, would load to their localhost which the server is not hosted at. I'm not quite sure why it can't use relative URL's but it does mention that the default config only works for localhost in the readme

I can see this screen, but I get this error message even before entering the password. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://local.revolt.chat:8000/.

That's on Firefox. On Chrome I don't exactly the same error messages

Failed to load resource: net::ERR_SOCKET_NOT_CONNECTED    :8000/1:

Uncaught (in promise) Error: Network Error         createError.js:16 
    at Np (vendor.aeef7222.js:12)
    at XMLHttpRequest.u.onerror (vendor.aeef7222.js:13)

I use Ubuntu 20.04.2 LTS

josealonso avatar Apr 04 '22 23:04 josealonso

I tried to do a complete Docker reset, but the containers still didn't work

Let that sink in

Not even docker system prune -a fixed the problem of .env not applying

haydenwalker980 avatar Apr 21 '22 18:04 haydenwalker980

Just dropping in to mention that I'm consolidating all issues regarding self-hosting into this issue. I'll probably eventually be able to get around to writing something up but I currently don't have any time.

insertish avatar Apr 29 '22 18:04 insertish

HE RESPONDS, finally this will actually be fixed

haydenwalker980 avatar Apr 30 '22 05:04 haydenwalker980