Opened 3 years ago

Last modified 3 years ago

#33065 closed Uncategorized

DisallowedHost exception when using server/container name to access django service — at Initial Version

Reported by: Robin Owned by: nobody
Component: Uncategorized Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello,

I am using the Django rest framework to provide REST API to other services.

All services have been packaged in docker. and all services are sharing data via the docker network.

Let's say, App A is calling App B(Django) APIs.

because they are on the same docker network then App A can call it like HTTP://server_B_container_name:8000/api/
But I got a DisallwedHost exception. The error message likes this:
"Invalid HTTP_HOST header: 'training_api'. The domain name provided is not valid according to RFC 1034/1035."

I have set the settings like this.
DJANGO_ALLOWED_HOSTS=localhost,training_api,*

It works if I call it through localhost or fully qualified domain name(port 8000 is exposed to host).

How can I call the Django via container name, not the IP? the IP will change every time it starts.

Thanks,
Robin

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top