khoj-ai / khoj

Your AI second brain. Get answers to your questions, whether they be online or in your own notes. Use online AI models (e.g gpt4) or private, local LLMs (e.g llama3). Self-host locally or use our cloud instance. Access from Obsidian, Emacs, Desktop app, Web or Whatsapp.
https://khoj.dev
GNU Affero General Public License v3.0
12.63k stars 640 forks source link

How to access admin when i use my domain? #608

Closed oanhcuongdo closed 8 months ago

oanhcuongdo commented 8 months ago

I use docker build. I can not access admin because django error domain not in allow_host. Please guide me fix it

debanjum commented 8 months ago

What is the domain that your Khoj server is running on?

You can set the KHOJ_DOMAIN environment variable to the domain your Khoj server is running on (in your docker-compose.yml or shell from where you start khoj via docker)

oanhcuongdo commented 8 months ago

hello, i config as you suggest: - POSTGRES_DB=postgres

sabaimran commented 8 months ago

Hi @oanhcuongdo , are you using Safari? Which browser are you on? Can you try setting KHOJ_DEBUG=True in your docker-compose and loading from Firefox to see if that helps?

uPagge commented 8 months ago

I started docker-compose and got the same problem.

uPagge commented 8 months ago

And it really doesn't work in Safari, but it works in Google Chrome

sabaimran commented 8 months ago

Ah yeah, the admin page completely doesn't work in Safari. This is also in the documentation!. Safari is really finnicky with storing cookies, which are necessary for storing the authentication credentials.

Seeing as it's working in Chrome and the Safari error is expected, I'll close this ticket. Let me know if y'all run into additional errors.

Jayddo commented 7 months ago

I am also getting this very same error as in the screenshot, on a mac, on windows, using chromium, firefox and edge.

it wasn't loading the page at all, but by adding KHOJ_DOMAIN I got to a login screen at least. The error happens afterwards. I have tried private tabs as well.

Not sure what else to try. I am running it on linux, unraid, with the sample docker compose

sabaimran commented 7 months ago

@Jayddo

I'd tested this a while ago, but we'll go through some additional testing again + improve the documentation.

Jayddo commented 7 months ago

my case is a bit different I suppose due to installing it on unraid. I tried following the instructions and using the sample docker compose, changing volumes to what my actual volumes are.

update: by using the localsetupwithmanynumbers.myunraid.net and adding myunraid.net as the domain, I get the same error. It still loads the auth, however, without the khoj_domain variable it does not. I have tried both the actual subdomain.myunraid.net as well as just unraid.net, in both cases the error is the same, on multiple browsers.

debanjum commented 7 months ago

Is your custom domain behind https? Otherwise this maybe triggered to the CSRF token only being allowed for KHOJ_DOMAIN behind an https endpoint. See the CSRF_TRUSTED_ORIGINS being set in settings.py

Jayddo commented 7 months ago

Custom domain has a letsencrypt certificate, but it is also available on normal http. I see what you mean, but what can I do about that? Would it be possible to just... disable this admin login? Khoj sits behind a closed network I can only access via vpn anyway, in my specific case.

Jayddo commented 6 months ago

anything I can try or do @sabaimran ?

from the look of things it seems like ssl the unraid ssl doesn't work for that particular port/khoj, so I seem to have this issue because of the CSRF token only allowed behind the https endpoint, as surmised by debanjum.

I would rather disable the backend auth altogether if it's not an easy fix, but I'd be happy to try some more things.

While my setup is non-standard, unraid is very popular so it's probably not going to be uncommon as khoj gets more popular.