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
AWS
Marco
질문됨 2년 전1157회 조회
1개 답변
1
수락된 답변

No, you can't remove those headers. Even if you could, the IP addresses would still identify it as a CloudFront source.

profile pictureAWS
전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠