Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Bad Request (400) running in docker #745

Closed
3 of 14 tasks
techieanant opened this issue May 23, 2024 · 3 comments
Closed
3 of 14 tasks

[FIX] Bad Request (400) running in docker #745

techieanant opened this issue May 23, 2024 · 3 comments
Labels
docker fix Fix something that isn't working as expected

Comments

@techieanant
Copy link

techieanant commented May 23, 2024

Describe the bug

I'm running Khoj docker compose stack on a server on my local network, have all the env variables setup but visiting /server/admin route throws a 400 Bad Request error. The logs show the following error:

 DisallowedHost: Invalid HTTP_HOST                    

 header: '10.0.0.197:42110'. You may                  

 need to add '10.0.0.197' to                          

 ALLOWED_HOSTS.

There seems to be no way to add a environment variable for setting allowed hosts.

To Reproduce

Steps to reproduce the behavior:

  • Run Khoj docker compose stack on a server on your network
  • Try to visit the admin route and see error

Screenshots

image

Platform

  • Server:
    • Cloud-Hosted (https://app.khoj.dev)
    • Self-Hosted Docker
    • Self-Hosted Python package
    • Self-Hosted source code
  • Client:
    • Obsidian
    • Emacs
    • Desktop app
    • Web browser
    • WhatsApp
  • OS:
    • Windows
    • macOS
    • Linux
    • Android
    • iOS

If self-hosted

  • Server Version [e.g. 1.0.1]: 1.12

Additional context

Add any other context about the problem here.

@techieanant techieanant added the fix Fix something that isn't working as expected label May 23, 2024
@sabaimran
Copy link
Member

Hey @techieanant , I'm assuming you can't access it over localhost?

You must have used the docker-compose.yml sample file to scaffold you Khoj instance. You can use that to set the environment variable KHOJ_DOMAIN. There are some notes about that here: https://docs.khoj.dev/get-started/setup/#setup-notes.

@techieanant
Copy link
Author

Thank you that worked although I now see a different problem.

image

@debanjum
Copy link
Member

Hi folks, I was able to verify that the latest Khoj run via Docker does not hit the CSRF or the Bad Request (400) issue when accessing the admin panel. As previously mentioned you need to set the KHOJ_DOMAIN environment variable to resolve the Bad Request issue.

I've also simplified the Docker setup in #919, so configuring Khoj via the admin panel isn't necessary to start using self hosted Khoj.

Do try the latest docker-compose.yml and Khoj docker image to see if the issue is resolved for you? You can see the new Remote Access Doc and the updated Self Hosting Setup Docs if you're still stuck.

And let me know if you're still hitting the issue, where/how you're running Khoj and client or server console logs to help debug this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker fix Fix something that isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants