2026-10-09 10:39:50 +02:00
|
|
|
# Géré par Ansible (rôle portail) — ne pas modifier à la main.
|
|
|
|
|
{% macro bloc_portail() %}
|
2026-10-08 02:01:58 +02:00
|
|
|
root {{ portail_dossier_app }}/public;
|
|
|
|
|
index index.php;
|
|
|
|
|
|
|
|
|
|
client_max_body_size 20m;
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
try_files $uri $uri/ /index.php?$query_string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-08 09:35:16 +02:00
|
|
|
# Relaie la console série (étape 9) en WebSocket vers le proxy Go. Le
|
|
|
|
|
# jeton après /console/ est à usage court (5 min), jamais l'URL Nova.
|
|
|
|
|
location /console/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:8081/console/;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_read_timeout 1h;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-08 02:01:58 +02:00
|
|
|
location ~ \.php$ {
|
|
|
|
|
fastcgi_pass unix:/run/php/php{{ portail_php_version }}-fpm.sock;
|
|
|
|
|
fastcgi_index index.php;
|
|
|
|
|
include fastcgi_params;
|
|
|
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ /\.(?!well-known) {
|
|
|
|
|
deny all;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
access_log /var/log/nginx/portail-access.log;
|
|
|
|
|
error_log /var/log/nginx/portail-error.log;
|
2026-10-09 10:39:50 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
{% if portail_https_actif %}
|
|
|
|
|
# HTTP : tout part en HTTPS. Les noms connus gardent leur nom ; une requête
|
|
|
|
|
# sur l'IP ou un nom inconnu est envoyée vers le domaine principal.
|
|
|
|
|
server {
|
|
|
|
|
listen 80;
|
|
|
|
|
listen [::]:80;
|
|
|
|
|
server_name {{ portail_domaine }} {{ portail_domaines_alias | join(' ') }}{% if portail_statut_actif %} {{ portail_domaine_statut }}{% endif %};
|
|
|
|
|
server_tokens off;
|
|
|
|
|
# Dans une location (pas au niveau server) : la location exacte que
|
|
|
|
|
# certbot ajoute pour le défi ACME au renouvellement reste prioritaire.
|
|
|
|
|
location / {
|
|
|
|
|
return 301 https://$host$request_uri;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
listen 80 default_server;
|
|
|
|
|
listen [::]:80 default_server;
|
|
|
|
|
server_name _;
|
|
|
|
|
server_tokens off;
|
|
|
|
|
location / {
|
|
|
|
|
return 301 https://{{ portail_domaine }}$request_uri;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# www → domaine principal (une seule adresse canonique).
|
|
|
|
|
server {
|
|
|
|
|
listen 443 ssl http2;
|
|
|
|
|
listen [::]:443 ssl http2;
|
|
|
|
|
server_name {{ portail_domaines_alias | join(' ') }};
|
|
|
|
|
server_tokens off;
|
|
|
|
|
include snippets/syllabus-tls.conf;
|
|
|
|
|
include snippets/syllabus-entetes.conf;
|
|
|
|
|
return 301 https://{{ portail_domaine }}$request_uri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
listen 443 ssl http2 default_server;
|
|
|
|
|
listen [::]:443 ssl http2 default_server;
|
|
|
|
|
server_name {{ portail_domaine }};
|
|
|
|
|
server_tokens off;
|
|
|
|
|
include snippets/syllabus-tls.conf;
|
|
|
|
|
include snippets/syllabus-entetes.conf;
|
|
|
|
|
{{ bloc_portail() }}
|
|
|
|
|
}
|
|
|
|
|
{% if portail_statut_actif %}
|
|
|
|
|
|
|
|
|
|
# Page de statut publique d'Uptime Kuma, et RIEN d'autre : l'administration
|
|
|
|
|
# (tableau de bord, /socket.io, /metrics…) reste accessible par tunnel SSH
|
|
|
|
|
# uniquement. Chemins relevés dans server/routers/status-page-router.js.
|
|
|
|
|
server {
|
|
|
|
|
listen 443 ssl http2;
|
|
|
|
|
listen [::]:443 ssl http2;
|
|
|
|
|
server_name {{ portail_domaine_statut }};
|
|
|
|
|
server_tokens off;
|
|
|
|
|
include snippets/syllabus-tls.conf;
|
|
|
|
|
include snippets/syllabus-entetes.conf;
|
|
|
|
|
|
|
|
|
|
location = / {
|
|
|
|
|
return 302 /status/{{ portail_statut_slug }};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location ~ ^/(status/[a-z0-9-]+$|api/status-page/|assets/|upload/|icon\.svg$|favicon\.ico$|apple-touch-icon[a-z0-9-]*\.png$|robots\.txt$) {
|
|
|
|
|
limit_except GET HEAD {
|
|
|
|
|
deny all;
|
|
|
|
|
}
|
|
|
|
|
proxy_pass http://127.0.0.1:{{ portail_port_uptime_kuma }};
|
2026-10-09 10:50:30 +02:00
|
|
|
# Kuma 1.23 ne répond jamais pour un identifiant de page inconnu
|
|
|
|
|
# (constaté le 2026-10-09) : ne pas faire attendre le visiteur.
|
|
|
|
|
proxy_read_timeout 15s;
|
2026-10-09 10:39:50 +02:00
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
return 404;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
access_log /var/log/nginx/statut-access.log;
|
|
|
|
|
error_log /var/log/nginx/statut-error.log;
|
|
|
|
|
}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% else %}
|
|
|
|
|
# Avant le premier certificat : HTTP seul, avec les noms du domaine pour que
|
|
|
|
|
# certbot (authentificateur nginx) trouve le bon bloc.
|
|
|
|
|
server {
|
|
|
|
|
listen 80 default_server;
|
|
|
|
|
listen [::]:80 default_server;
|
|
|
|
|
server_name {{ portail_domaine }} {{ portail_domaines_alias | join(' ') }} _;
|
|
|
|
|
server_tokens off;
|
|
|
|
|
{{ bloc_portail() }}
|
2026-10-08 02:01:58 +02:00
|
|
|
}
|
2026-10-09 10:39:50 +02:00
|
|
|
{% endif %}
|