Open joejordan opened 8 months ago
Here's a manual solution that I found works. Edit the domain.com.conf
and add the following to the top of the config. This will explicitly redirect www traffic to non-www.
# www redirect directive
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.domain.com;
# Serve ACME challenge files from a specific location
location /.well-known/acme-challenge/ {
root /var/www/certbot/domain.com;
}
# Redirect all other requests to the non-www domain
location / {
return 301 https://domain.com$request_uri;
}
}
Prerequisites
Docker Compose Version and Environment
Docker Compose version: (run
docker-compose --version
and paste output here) Docker version 24.0.7, build afdd53bOperating System: AlmaLinux 9
Any specific configuration changes made from the default setup: None
Describe the Bug
When I added a subdomain, www did not automatically redirect to the non-www root url.
Expected Behavior
When www is not enabled on a domain, http and https www.domain.com should redirect to domain.com
Actual Behavior
http redirects to https but will display a certificate error because it's finding another sub-domain's certificate.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
Additional Context
N/A
Logs
N/A