Skip to content

API report URL is http:// link #1704

Description

@bwbroersma

domains.$domain.report.url starts with http://

Should be https://

Related code:

result["report"] = {"url": f"{site_url}{reverse(url_name, args=args)}"}

which uses:

def get_site_url(request):
"""
Compose the url that the user used to connect to the API.
"""
return f"{request.scheme}://{request.get_host()}"

But it probably does not have a real request context as a task, so the scheme defaults to http?

@batch_shared_task(bind=True, ignore_result=True)
def batch_async_generate_results(self, user, batch_request, site_url):


If it would be a real request, the following holds:

Because nginx is terminating the TLS, it sets a proxy header X-Forwarded-Proto with $scheme:

proxy_set_header X-Forwarded-Proto $scheme;

This requires that SECURE_PROXY_SSL_HEADER is set, which is conditionally set:

if DJANGO_IS_PROXIED:
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")

which is fetched by:

DJANGO_IS_PROXIED = get_boolean_env("DJANGO_IS_PROXIED", False)

and by default set on True:

- DJANGO_IS_PROXIED=True

The relevant Django 4.2.x code is here:
https://github.com/django/django/blob/stable/4.2.x/django/http/request.py#L246-L270

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

infrastructure-dockerIssues related to the underlying infrastructure of the project as well as containerization

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions