forked from CCCHH/ansible-infra
Move to the TLSRef configuration generators Intermediate configuration profile as of 2026-12-04 with HSTS on and OCSP Stapling off. https://configurator.tlsref.org/#server=nginx&version=1.27.3&config=intermediate&openssl=4.0.1&hsts&guideline=6.0 Adjust the nginx roles tls.conf accordingly, modernize the hosts configs use of http2 and remove statements previously used because of OCSP stapling (ssl_trusted_certificate and resolver). Don't do OCSP stapling anymore, since it's deprecated. https://letsencrypt.org/2024/12/05/ending-ocsp
64 lines
2.8 KiB
Markdown
64 lines
2.8 KiB
Markdown
# Role `nginx`
|
|
|
|
Ensures nginx is installed from the NGINX repos and setup as specified via the arguments.
|
|
|
|
## Supported Distributions
|
|
|
|
The following distributions are supported:
|
|
|
|
- Debian 11
|
|
- Debian 12
|
|
|
|
## Required Arguments
|
|
|
|
None.
|
|
|
|
## Optional Arguments
|
|
|
|
- `nginx__deploy_redirect_conf`: Whether or not to deploy a config redirecting from HTTP to HTTPS, while still forwarding the `/.well-known/acme-challenge/` to localhost Port 31820 for certificate issuing.
|
|
See [`files/redirect.conf`](./files/redirect.conf) for the configuration that would be deployed.
|
|
Defaults to `true`.
|
|
- `nginx__deploy_tls_conf`: Whether or not to deploy a config configuring some TLS settings reasonably.
|
|
See [`files/tls.conf`](./files/tls.conf) for the configuration that would be deployed.
|
|
Defaults to `true`.
|
|
- `nginx__deploy_logging_conf`: Whether or not to deploy a config configuring logging to journald.
|
|
See [`files/logging.conf`](./files/logging.conf) for the configuration that would be deployed.
|
|
Defaults to `true`.
|
|
- `nginx__configurations`: List of nginx configurations to ensure are deployed.
|
|
- `nginx__configurations.*.name`: This name with `.conf` appended will be used for the configurations file name under `/etc/nginx/conf.d/`.
|
|
`tls`, `redirect` and `logging` are reserved names.
|
|
- `nginx__configurations.*.content`: This configurations content.
|
|
- `nginx__use_custom_nginx_conf`: Whether or not to use a custom `/etc/nginx/nginx.conf`.
|
|
If set to true, you must provide the content for a custom `nginx.conf` via `nginx__custom_nginx_conf`.
|
|
Defaults to `false`.
|
|
- `nginx__custom_nginx_conf`: The content to use for the custom `nginx.conf`.
|
|
Needs `nginx__use_custom_nginx_conf` to be set to true to work.
|
|
You should probably still make sure that your custom `nginx.conf` includes `/etc/nginx/conf.d/*.conf`, so that the other configuration files still work.
|
|
|
|
## Config Template
|
|
|
|
Here's a config template, which can be used for new NGINX site configs, which you can supply to this role using the `nginx__configurations` argument.
|
|
Just replace the placeholder values with real ones and extend and edit it as needed.
|
|
|
|
```
|
|
# based on tlsref config
|
|
# generated 2026-12-04, TLSRef Guideline v6.0, nginx 1.27.3, OpenSSL 4.0.1, intermediate config, HSTS, gitrev=6bcb595
|
|
# https://configurator.tlsref.org/#server=nginx&version=1.27.3&config=intermediate&openssl=4.0.1&hsts&guideline=6.0
|
|
server {
|
|
listen 443 ssl;
|
|
#listen [::]:443 ssl;
|
|
http2 on;
|
|
|
|
server_name replace_me;
|
|
|
|
ssl_certificate /path/to/signed_cert_plus_intermediates;
|
|
ssl_certificate_key /path/to/private_key;
|
|
|
|
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
|
|
add_header Strict-Transport-Security "max-age=63072000" always;
|
|
}
|
|
```
|
|
|
|
## Links & Resources
|
|
|
|
- <https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#installing-prebuilt-debian-packages>
|