rhythmic-tailor-1242
01/16/2023, 6:30 PM<http://example.com|example.com>
and I'm able to load <https://example.com>
I now want to make sure <https://www.example.com>
gets redirected to <https://example.com>
Any idea how to do it?
This is my code right now:
// Step 2: Define the Networking for our service.
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer(
"net-lb",{
external: true,
vpc,
subnets: vpcData.subnets.public,
securityGroups: cluster.securityGroups,
});
// Target group with the port of the Docker image
const target = alb.createTargetGroup(
"web-target", {vpc, port: PORT}
);
// Listen to traffic on port 443 & route it through the target group
const httpsListener = target.createListener("web-listener", {
port: 443,
certificateArn: certificateValidation.certificateArn
});
const web = alb.createListener("nginx", {
// const web = new awsx.elasticloadbalancingv2.ApplicationListener("nginx", {
port: PORT,
protocol: "HTTP",
defaultAction: {
type: "redirect",
redirect: {
protocol: "HTTPS",
host: `${DOMAIN}`,
port: "443",
statusCode: "HTTP_301"
},
},
})
new aws.route53.Record(`<http://example.com|example.com>`, {
name: `<http://example.com|example.com>`,
zoneId: hostedZoneId,
type: "A",
aliases: [{
name: httpsListener.endpoint.hostname,
zoneId: alb.loadBalancer.zoneId,
evaluateTargetHealth: true
}],
});
billowy-army-68599
01/16/2023, 6:47 PMrhythmic-tailor-1242
01/16/2023, 8:47 PMwww
still doesn't work:
const target = alb.createTargetGroup(
"web-target", {vpc: unikVpc, port: PORT}
);
const httpsListener = target.createListener("web-listener", {
port: 443,
certificateArn: certificateValidation.certificateArn
});
httpsListener.addListenerRule("nginx", {
actions: [{
type: "redirect",
redirect: {
host: "unik.style",
protocol: "HTTPS",
port: "443",
statusCode: "HTTP_301",
},
}],
conditions: [{
hostHeader: {
values: ["unik.style", "www.unik.style"],
},
}],
})