I have deployed a LEMP stack to Linode and purchased a Wildcard SSL Certificate.
Prior to installing the SSL Certificate, I could type in example.com.au
OR www.example.com.au
and it would bring up the same HTTP website.
After installing the SSL Certificate, I only successfully reach the website when I type in www.example.com.au
I’ve tried setting the server_name
inside of the server blocks in the nginx configuration, however, it doesn’t seem to have any effect on it.
Here is my nginx configuration file.
Note – I’m deploying WordPress using docker
upstream php {
#server unix:/tmp/php-cgi.socket;
server php:9000;
}
server {
listen 80;
listen (::):80;
server_name *.example.com.au;
return 301 https://$host$request_uri;
}
server {
listen 80;
listen (::):80;
server_name example.com.au; # <-- this doesnt help at all
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name *.example.com.au;
ssl_certificate /etc/nginx/certs/bundle.crt;
ssl_certificate_key /etc/nginx/certs/example.com.au.key;
root /var/www/html;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Does anyone have a solution? When I look at the request details in the network tab, I don’t see a “Host” header being sent when typing example.com.au
in the URL bar of the browser… but it is present when I type in www.example.com.au
Thanks