#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         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 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

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33065>
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/052.f26b5d109f95e73ea9a8fa70c50e2cc0%40djangoproject.com.

Reply via email to