Skip to content

Correct protocol on context.request.url when behind reverse proxy #246

@elf-pavlik

Description

@elf-pavlik

I started running the SAI service behind a reverse proxy, which terminates HTTPS. I'm not sure how to get the correct context.request.url. I get http instead of https.

In CSS they use the 'X-Forwarded-Proto' header on the request. As shown in this snippet:

https://github.com/solid/solidproject.org/wiki/Using-NGINX-as-a-reverse-proxy#configuration

Also seen in code: https://github.com/CommunitySolidServer/CommunitySolidServer/blob/4599bf413e0ca08725d22b5e01fe43e97ef7d714/src/http/input/identifier/OriginalUrlExtractor.ts#L46-L53

I wasn't able to find how the same can be achieved in handlersjs.

After a quick look at the code, I found one place where http seems to be hardcoded

const urlObject: URL = new URL(url.replace(/^\/+/, '/'), `http://${nodeHttpStreams.requestStream.headers.host}`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions