Files
computer-playbook/roles/web-opt-rdr-www
Kevin Veen-Birkenbach f36c7831b1 Implement dynamic TimeoutStartSec filter for domains and update roles
- Added new filter plugin 'timeout_start_sec_for_domains' to calculate TimeoutStartSec based on number of domains.
- Updated sys-ctl-hlth-csp and sys-ctl-hlth-webserver tasks to use the filter.
- Removed obsolete systemctl.service.j2 in sys-ctl-hlth-csp.
- Adjusted variable naming (CURRENT_PLAY_DOMAINS_ALL etc.) in multiple roles.
- Updated srv-letsencrypt and sys-svc-certs to use uppercase vars.
- Switched pretix role to sys-stk-full-stateful and removed leftover javascript.js.
- Added unittests for the new filter under tests/unit/filter_plugins.

See conversation: https://chatgpt.com/share/68b1ae9a-1ac0-800f-b49d-2915386a1a23
2025-08-29 15:44:31 +02:00
..

Nginx WWW Redirect 🌐

Description

Automates the creation of Nginx server blocks that redirect all www. subdomains to their non-www equivalents. Simple, idempotent, and SEO-friendly! 🚀

Overview

This role will:

  • Discover existing *.conf vhosts in your Nginx servers directory
  • Filter domains with or without your PRIMARY_DOMAIN
  • Generate redirect rules via the web-opt-rdr-domains role
  • Optionally include a wildcard redirect template (experimental)
  • Clean up leftover configs when running in cleanup mode 🧹

All tasks are guarded by “run once” facts and MODE_CLEANUP flags to avoid unintended re-runs or stale files.

Purpose

Ensure that any request to www.example.com automatically and permanently redirects to https://example.com, improving user experience, SEO, and certificate management. 🎯

Features

  • Auto-Discovery: Scans your Nginx servers directory for .conf files. 🔍
  • Dynamic Redirects: Builds source: "www.domain"target: "domain" mappings on the fly. 🔧
  • Wildcard Redirect: Includes a templated wildcard server block for www.* domains (toggleable).
  • Cleanup Mode: Removes the wildcard config file when CERTBOT_FLAVOR is set to dedicated and MODE_CLEANUP is enabled. 🗑️
  • Debug Output: Optional MODE_DEBUG gives detailed variable dumps for troubleshooting. 🐛