Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use x-forwarded-host header in the info.json's @id if present #77

Closed
1 task
mbklein opened this issue Jul 15, 2022 · 1 comment
Closed
1 task

Use x-forwarded-host header in the info.json's @id if present #77

mbklein opened this issue Jul 15, 2022 · 1 comment
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@mbklein
Copy link
Member

mbklein commented Jul 15, 2022

Description

When accessed through CloudFront, the @id field of the info.json file is using the standalone function URL as the base instead of the CloudFront domain URL.

Done Looks Like

  • @id is correct when accessed via standalone or CloudFront
@mbklein mbklein added the bug Something isn't working label Jul 15, 2022
@mbklein mbklein changed the title Use x-forwarded-for header in the info.json's @id if present Use x-forwarded-host header in the info.json's @id if present Jul 15, 2022
@mbklein
Copy link
Member Author

mbklein commented Jul 15, 2022

This issue cannot be fixed automatically. serverless-iiif already supports overriding the domain name two different ways:

  • Setting the Lambda function's forceHost environment variable to the desired hostname
  • Passing an x-forwarded-host header from CloudFront

Both of these methods are already working correctly in the code. The problem is that:

  • CloudFront does not automatically include its own domain name in the x-forwarded-host header
  • SAM/CloudFormation can't resolve the CloudFront domain name at deploy time to set it as a custom origin header or to set the Lambda function's forceHost variable

The only ways to get this working at the moment would be:

  • After deploying, manually update either the forceHost environment variable on the lambda or add an x-forwarded-host header to the lambda origin on the CloudFront distribution, with the value being the domain name of the CloudFront distribution
  • Add a Viewer-Request function to copy the contents of the incoming Host header to x-forwarded-host
  • Use a custom domain name (which already sets forceHost)

None of these is a perfect solution to the problem, especially since every redeploy/update will wipe out the manual configuration. It might be possible to store the lambda function's configuration somewhere else (like in Parameter Store or Secrets Manager), which would make this easy. But then we'd incur the overhead of fetching the configuration on every invocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant