Ansible playbook to setup a redirection server from your root domain name to wwww subdomain using Let's encrypt on nginx.
The Ansible playbook installs nginx and let's encrypt to redirect https://example.com to https://www.example.com. The server pass A rating on SSL Labs.
To use:
- Install Ansible
- Setup an Ubuntu 16.04 server accessible over ssh
- Create
/etc/ansible/hosts
according to template below and change example.com to your domain - Copy the rest of the files to an empty directory (
playbook.yml
in the root of that folder and the rest in thetemplates
subfolder) - Run
ansible-playbook playbook.yml
- Restart nginx (
systemctl restart nginx
)
thanks for the scripts. IMO rewrite like
cripples the outcome a bit, since certificate is for
{{ domain_name }}
, but redirect forces to dowww.{{ domain_name }}
, in which case the certificate does not match the site address. to mewww
prefix looks redundant anyway these days.