I have developed a Django project that makes use of the django-hosts library and now I am trying to deploy it. After working through the Zappa tutorials, I became convinced that Zappa was the way to go. However, I later realized that API Gateway does not support wildcard subdomains. While this is not strictly a Zappa issue, I was wondering if there was anyone who had any success in circumventing this issue since it doesn't look like the API Gateway developers have any intention of enabling this in the near future.
Expected Behavior
Allow *.example.com to host a Django project and let Django map to a view based on the subdomain.
Actual Behavior
Wildcard subdomains are not permitted by API Gateway; only subdomains that are explicitly defined are passed.
Possible Fix
I tried to manually create a CloudFront distribution that allows "*.example.com" as a CNAME and set the raw API gateway URL as the origin. However, due to CloudFront's default caching behavior, the problem then becomes that any subdomain (e.g. api.example.com) returns a 301 redirect to the raw API Gateway URL. Not sure how the hidden CloudFront distribution created via the Custom Domains tab in API Gateway handles this.
Steps to Reproduce (for possible fix)
Create a CloudFront distribution and select 'Web' Distribution
Use the Zappa distribution domain name from API Gateway as the Origin Domain Name,(e.g. ajnfioanpsda.execute-api.us-east-1.amazonaws.com)
For alternate domain names, enter in "*.example.com, example.com"
Use the Zappa deployment name (e.g. dev) as the Origin Path
For Object Caching select 'Use Origin Cache Headers'
Turn on "compress objects automatically"
Associate the CloudFront distribution with your ACM SSL/TLS certificate
Context
I have developed a Django project that makes use of the django-hosts library and now I am trying to deploy it. After working through the Zappa tutorials, I became convinced that Zappa was the way to go. However, I later realized that API Gateway does not support wildcard subdomains. While this is not strictly a Zappa issue, I was wondering if there was anyone who had any success in circumventing this issue since it doesn't look like the API Gateway developers have any intention of enabling this in the near future.
Expected Behavior
Allow *.example.com to host a Django project and let Django map to a view based on the subdomain.
Actual Behavior
Wildcard subdomains are not permitted by API Gateway; only subdomains that are explicitly defined are passed.
Possible Fix
I tried to manually create a CloudFront distribution that allows "*.example.com" as a CNAME and set the raw API gateway URL as the origin. However, due to CloudFront's default caching behavior, the problem then becomes that any subdomain (e.g. api.example.com) returns a 301 redirect to the raw API Gateway URL. Not sure how the hidden CloudFront distribution created via the Custom Domains tab in API Gateway handles this.
Steps to Reproduce (for possible fix)