cookiecutter / cookiecutter-django

Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
https://cookiecutter-django.readthedocs.io
BSD 3-Clause "New" or "Revised" License
11.95k stars 2.87k forks source link

https://my-dev-env.local serving pages from both django and docs containers #2840

Closed SeraphimSG closed 1 month ago

SeraphimSG commented 3 years ago

What happened?

After implementing the steps described under the "Developing locally with HTTPS" section of the docs, https://my-dev-env.local served pages randomly from both the django and docs containers, resulting in returning successful pages (200) at times and returning 404 page not found errors at other times.

What should've happened instead?

https://my-dev-env.local should only serve pages from the django container.

Additional details

From my observations, this is due to both django and docs containers being included within the "upstream" section of the generated nginx-proxy '/etc/nginx/conf.d/default.conf' file.

This is in turn caused by both django: and docs: within local.yml pointing to the same .env file (/.envs/.local/.django). Hence when VIRTUAL_HOST and VIRTUAL_PORT are added to this .env file (as instructed in the docs), they ended up linking nginx-proxy to both django and docs containers.

As a workaround, I simply created a /.envs/.local/.docs, pointed to this new env file in local.yml (under docs:), rebuilt the containers, and https://my-dev-env.local is serving everything properly now.

I'm wondering if there's a more elegant way around this or is there something I may have missed out in my set up?

asencis commented 3 years ago

I can confirm that I am also seeing this issue.

asencis commented 3 years ago

The "fix" for me was to temporarily remove flower and docs from the local.yml file.

browniebroke commented 3 years ago

@Afrowave this bug report relates to a part you contributed in the documentation (#2664).

I don't really use this extension and therefore I'm not really familiar with how to fix it. Since it's not really part of the template, it's a page which very likely to get outdated, therefore I'm edging on the side of removing it from our documentation. If you want to turn it into a blog post, we could link to it instead.

Let me know what you think.

asencis commented 3 years ago

Would it not be possible to add django-sslserver as an option? I've never had it fail on me yet ... https://github.com/teddziuba/django-sslserver

However, adding this package would require dropping uvicorn, which wouldn't be compatible with an async server.

Afrowave commented 3 years ago

Hey @browniebroke,

Let me fix this and give both options.

linusthe3rd commented 3 years ago

django and docs are both loading because they both use .envs/.local/.django, which confuses the nginx environment variable configuration.