#33065: DisallowedHost exception when using server/container name to access 
django
service
-------------------------------+--------------------------------------
     Reporter:  ziyunxiao      |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Uncategorized  |                  Version:  3.2
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Description changed by ziyunxiao:

Old 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

New 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 on the host, or container IP
 inside App A container or a fully qualified domain name of the host(port
 8000 is exposed to host) from other machines.

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

 Thanks,
 Robin

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33065#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.6d4f7b4d0332676a6a8a404e3216f1f0%40djangoproject.com.

Reply via email to