Interface IResponseHeadersPolicyProps
Properties for creating a Response Headers Policy.
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IResponseHeadersPolicyProps
Syntax (vb)
Public Interface IResponseHeadersPolicyProps
Remarks
ExampleMetadata: infused
Examples
// Using an existing managed response headers policy
S3Origin bucketOrigin;
new Distribution(this, "myDistManagedPolicy", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = bucketOrigin,
ResponseHeadersPolicy = ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS
}
});
// Creating a custom response headers policy -- all parameters optional
var myResponseHeadersPolicy = new ResponseHeadersPolicy(this, "ResponseHeadersPolicy", new ResponseHeadersPolicyProps {
ResponseHeadersPolicyName = "MyPolicy",
Comment = "A default policy",
CorsBehavior = new ResponseHeadersCorsBehavior {
AccessControlAllowCredentials = false,
AccessControlAllowHeaders = new [] { "X-Custom-Header-1", "X-Custom-Header-2" },
AccessControlAllowMethods = new [] { "GET", "POST" },
AccessControlAllowOrigins = new [] { "*" },
AccessControlExposeHeaders = new [] { "X-Custom-Header-1", "X-Custom-Header-2" },
AccessControlMaxAge = Duration.Seconds(600),
OriginOverride = true
},
CustomHeadersBehavior = new ResponseCustomHeadersBehavior {
CustomHeaders = new [] { new ResponseCustomHeader { Header = "X-Amz-Date", Value = "some-value", Override = true }, new ResponseCustomHeader { Header = "X-Amz-Security-Token", Value = "some-value", Override = false } }
},
SecurityHeadersBehavior = new ResponseSecurityHeadersBehavior {
ContentSecurityPolicy = new ResponseHeadersContentSecurityPolicy { ContentSecurityPolicy = "default-src https:;", Override = true },
ContentTypeOptions = new ResponseHeadersContentTypeOptions { Override = true },
FrameOptions = new ResponseHeadersFrameOptions { FrameOption = HeadersFrameOption.DENY, Override = true },
ReferrerPolicy = new ResponseHeadersReferrerPolicy { ReferrerPolicy = HeadersReferrerPolicy.NO_REFERRER, Override = true },
StrictTransportSecurity = new ResponseHeadersStrictTransportSecurity { AccessControlMaxAge = Duration.Seconds(600), IncludeSubdomains = true, Override = true },
XssProtection = new ResponseHeadersXSSProtection { Protection = true, ModeBlock = false, ReportUri = "https://example.com/csp-report", Override = true }
},
RemoveHeaders = new [] { "Server" },
ServerTimingSamplingRate = 50
});
new Distribution(this, "myDistCustomPolicy", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = bucketOrigin,
ResponseHeadersPolicy = myResponseHeadersPolicy
}
});
Synopsis
Properties
Comment | A comment to describe the response headers policy. |
CorsBehavior | A configuration for a set of HTTP response headers that are used for cross-origin resource sharing (CORS). |
CustomHeadersBehavior | A configuration for a set of custom HTTP response headers. |
RemoveHeaders | A list of HTTP response headers that CloudFront removes from HTTP responses that it sends to viewers. |
ResponseHeadersPolicyName | A unique name to identify the response headers policy. |
SecurityHeadersBehavior | A configuration for a set of security-related HTTP response headers. |
ServerTimingSamplingRate | The percentage of responses that you want CloudFront to add the Server-Timing header to. |
Properties
Comment
A comment to describe the response headers policy.
virtual string Comment { get; }
Property Value
System.String
Remarks
Default: - no comment
CorsBehavior
A configuration for a set of HTTP response headers that are used for cross-origin resource sharing (CORS).
virtual IResponseHeadersCorsBehavior CorsBehavior { get; }
Property Value
Remarks
Default: - no cors behavior
CustomHeadersBehavior
A configuration for a set of custom HTTP response headers.
virtual IResponseCustomHeadersBehavior CustomHeadersBehavior { get; }
Property Value
IResponseCustomHeadersBehavior
Remarks
Default: - no custom headers behavior
RemoveHeaders
A list of HTTP response headers that CloudFront removes from HTTP responses that it sends to viewers.
virtual string[] RemoveHeaders { get; }
Property Value
System.String[]
Remarks
Default: - no headers are removed
ResponseHeadersPolicyName
A unique name to identify the response headers policy.
virtual string ResponseHeadersPolicyName { get; }
Property Value
System.String
Remarks
Default: - generated from the id
SecurityHeadersBehavior
A configuration for a set of security-related HTTP response headers.
virtual IResponseSecurityHeadersBehavior SecurityHeadersBehavior { get; }
Property Value
IResponseSecurityHeadersBehavior
Remarks
Default: - no security headers behavior
ServerTimingSamplingRate
The percentage of responses that you want CloudFront to add the Server-Timing header to.
virtual Nullable<double> ServerTimingSamplingRate { get; }
Property Value
System.Nullable<System.Double>
Remarks
Default: - no Server-Timing header is added to HTTP responses