remove default headers from lambda@edge viewer request
0
I built a lambda@edge that I use to authenticate calls on viewer request. If a request is rejected I want to play back as few information as possible to the caller and therefore want to remove some headers indicating I am using AWS. I found a way to override headers simply by returning a new value for that header, see server in the example.
But how can I remove the x-amz-cf-id or x-cache headers to not indicate the backend is running on AWS?
import json
def lambda_handler(event, context):
response = event["Records"][0]["cf"]["request"]
headers = response["headers"]
#check authentication... omitted
#....
response = {
'status': status,
'statusDescription': status_desc,
'headers': {
'server': [
{
'key': 'server',
'value': 'x'
}
]
}
}
return response
asked 3 months ago10 views
1 Answers
1
Accepted Answer
No, you can't remove those headers. Even if you could, the IP addresses would still identify it as a CloudFront source.
Relevant questions
Cost Explorer for Lambda@Edge
Accepted Answerasked a year ago400 The parameter Headers contains Authorization that is not allowed
asked 2 years agoLambda@Edge - Maximum number of distributions with Lambda function exceeded
asked 5 years agoHow to make Lambda + API Gateway obey REQUEST_URI?
asked a month agoCloudFront host headers rejected by ISTIO
Accepted Answerasked 2 years agoUnable to delete lambda replica
asked 3 months agoCan I fully authenticate to AWS iOT through API Gateway HTTP using only header authentication methods?
asked 3 months agoAPI Gateway Dynamic routing
Accepted Answerasked 2 years agoremove default headers from lambda@edge viewer request
Accepted Answerasked 3 months agoCannot deploy lambda on edge
asked 2 years ago