Hello Cloud Gurus,
Very strange issue and hope you will have a good solution for this issue. I think it might be solution from CloudFront side and is not necessary to edit any code in web server.
So here is the scenario:
Every time I am deploying cloudfront in AWS for a dynamic website it gives me some problem.
For example if cloudfront is deployed for domain example.com and web server is in ec2 based on apache, everytime I make get request from browser to example.com it returns me ec2 server hostname like: ec2-18-125-214-123.us-east-2.compute.amazonaws.com or something like this. As you know it is ec2's default DNS address given from AWS.
How can I fix this without making editing in Apache? (Without Set domain name manually in a code. Configuration in Apache looking for servers host address itself). Cloudfront is configured to redirect http to https and everything other is default. Only using certificate generated from aws cert manager for this domain.
Today I set URL manually in Apache like https://example.com and it fixed but it is often that site developer has own site engine and do not want to change anything and site host are dynamic for them. Then comes a mixed content and I am getting a cloudfront problem even it changes me web address in the browser (when I am going web site's different pages and it returns me such kind of link >ec2-18-125-214-123.us-east-2.compute.amazonaws.com/contact < for example), or even website is loading not with fully safe certificate and browser (F12 - Console) shows me "Mixed Content"
How should I fix this at cloudfront side?
P.S.
Here are shown my CloudFront configuration when I have this upper problem:
Origin Domain Name: ec2-18-125-214-123.us-east-2.compute.amazonaws.com
Origin Path: Is Default (Empty)
Origin ID: I tried to make even "ec2-18-125-214-123.us-east-2.compute.amazonaws.com" or even domain name like "example.com"
Minimum Origin SSL Protocol: Default
Origin Protocol Policy: Default
Origin Response Timeout: Default
Origin Keep-alive Timeout: Default
HTTP Port: Default
HTTPS Port: Default
Origin Custom Headers: Default
Path Pattern: Default (*)
Origin or Origin Group: It depend what I will chose "ec2-18-125-214-123.us-east-2.compute.amazonaws.com" or even domain name like "example.com"
Viewer Protocol Policy: Redirect HTTP to HTTPS
Allowed HTTP Methods: Default (GET, HEAD)
Cached HTTP Methods: Default
Cache Based on Selected Request Headers: Default (I also tried "Whitelist Headers" For "HOST")
Object Caching: Use Origin Cache Headers
Minimum TTL: Default
Maximum TTL: Default
Default TTL: Default
Forward Cookies: Default
Query String Forwarding and Caching: Default
Smooth Streaming: Default
Restrict Viewer Access (Use Signed URLs or Signed Cookies): Default (NO)
Compress Objects Automatically: Default (NO)
Lambda Function Associations: Default
HI Scott, Thank you for your answer. But I am not using default SSL, I am using SSL for my own domain generated in AWS Cert Managar.