vi /etc/nginx/sites-available/geonature.conf
server { listen 80; listen [::]:80; server_name <alias>.<domaine-sinp>; root /home/geonat/www/geonature/frontend/dist; location ^~ "/api/" { proxy_set_header X-Forwarded-Host $host:$server_port; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # WARNING: up timeout to 300s for Synthese downloading (See bug ) # Set timeout like Gunicorn in GeoNature config/settings.ini file proxy_read_timeout 300s; proxy_connect_timeout 75s; proxy_pass http://127.0.0.1:8000/api/;# ATTENTION : bien mettre un slash final ! Sinon => 404 } }
cd /etc/nginx/sites-enabled/ ; ln -s ../sites-available/geonature.conf geonature.conf
nginx -t && nginx -s reload
systemctl status geonature.service
systemctl start geonature
systemctl stop geonature
dist
de GeoNature n'existe pas.dist
est supprimé puis recréé uniquement à la fin du build.rsync -av --size-only ./maintenance geonat@web-<region>-sinp:/home/geonat/www/
# Set root path set $root_path /home/geonat/www/geonature/frontend/dist; if (!-d /home/geonat/www/geonature/frontend/dist) { set $root_path /home/geonat/www/maintenance/geonature; } root $root_path;
certbot --nginx -d <alias>.<domaine-sinp> -d geonature.<domaine-sinp>
certbot --nginx -d expert.silene.eu -d geonature.silene.eu
certbot --nginx \ -d donnees.biodiversite-auvergne-rhone-alpes.fr -d geonature.biodiversite-auvergne-rhone-alpes.fr \ -d donnees.biodiversite-auvergne-rhone-alpes.com -d geonature.biodiversite-auvergne-rhone-alpes.com \ -d donnees.biodiversite-auvergne-rhone-alpes.eu -d geonature.biodiversite-auvergne-rhone-alpes.eu \ -d donnees.biodiversite-auvergne-rhone-alpes.net -d geonature.biodiversite-auvergne-rhone-alpes.net \ -d donnees.biodiversite-auvergne-rhone-alpes.org -d geonature.biodiversite-auvergne-rhone-alpes.org \ -d donnees.biodiversite-aura.com -d geonature.biodiversite-aura.com \ -d donnees.biodiversite-aura.eu -d geonature.biodiversite-aura.eu \ -d donnees.biodiversite-aura.fr -d geonature.biodiversite-aura.fr \ -d donnees.biodiversite-aura.net -d geonature.biodiversite-aura.net \ -d donnees.biodiversite-aura.org -d geonature.biodiversite-aura.org \ -d donnees.observatoire-biodiversite-auvergne-rhone-alpes.com -d geonature.observatoire-biodiversite-auvergne-rhone-alpes.com \ -d donnees.observatoire-biodiversite-auvergne-rhone-alpes.eu -d geonature.observatoire-biodiversite-auvergne-rhone-alpes.eu \ -d donnees.observatoire-biodiversite-auvergne-rhone-alpes.fr -d geonature.observatoire-biodiversite-auvergne-rhone-alpes.fr \ -d donnees.observatoire-biodiversite-auvergne-rhone-alpes.net -d geonature.observatoire-biodiversite-auvergne-rhone-alpes.net \ -d donnees.observatoire-biodiversite-auvergne-rhone-alpes.org -d geonature.observatoire-biodiversite-auvergne-rhone-alpes.org
~/www/maintenance/
en les transférant depuis le dépôt sinp-<region>-srv à l'aide de rsync.server { listen 443 ssl http2; # managed by Certbot listen [::]:443 ssl http2; # managed by Certbot server_name <alias>.<domaine-sinp>; # Set maintenance mode # Define root paths set $base_root_path /home/geonat/www; set $geonature_root_path $base_root_path/geonature/frontend/dist; set $maintenance_root_path $base_root_path/maintenance/geonature; # Disable maintenance mode by default set $maintenance off; # Activate maintenance mode ("short") if GeoNatue is being recompiled if (!-d $geonature_root_path) { set $maintenance on; set $maintenance_duration "short"; } # Activate maintenance mode ("long") if file "maintenance.enable" exists if (-f $maintenance_root_path/maintenance.enable) { set $maintenance on; set $maintenance_duration "long"; } # Disable maintenance mode if user browser send a cookie named "maintenance_disable" with a specific UUID value if ($cookie_maintenance_disable = "<uuid-maintenance-disable>") { set $maintenance off; } # Disable maintenance mode for specific IP (default web server IP) if ($remote_addr ~ (51.91.137.130)) { set $maintenance off; } # Disable maintenance mode for the URI with the path to the shared CSS, JS, or images used in the maintenance page. if ($uri ~ "^/maintenance/shared/") { set $maintenance off; } # Return HTTP code 503 (service unavailable) if maintenance is on if ($maintenance = on) { return 503; } error_page 503 @maintenance; # Display the long or short term maintenance page. location @maintenance { root $maintenance_root_path; rewrite ^(.*)$ "/maintenance.$maintenance_duration.html" break; } # Set root path root $geonature_root_path; # Change root path for shared files used in the maintenance page. location ~ "^/maintenance/shared/" { root $base_root_path; } # GeoNature Angular App # No cache for index.html Angular App and config/locale json files location ~* "^/index.html|.*\.json$" { expires -1; add_header Cache-Control "no-store"; } # Favicon location "/favicon.ico" { expires 1y; add_header Cache-Control "public, no-transform"; } # JS and CSS location ~* "^/[^/]+\.[0-9a-f]{20}\.(?:js|css)$" { expires 1y; add_header Cache-Control "public, immutable"; } # Images location ~* "^/[^/]+\.[0-9a-f]{20}\.(?:gif|jpe?g|png|svg)$" { expires 1y; add_header Cache-Control "public, no-transform, immutable"; } # Fonts location ~* "^/[^/]+\.[0-9a-f]{20}\.(?:woff2?|eot|ttf)$" { expires 1y; add_header Cache-Control "public, immutable"; } # GeoNature API location ^~ "/api/" { proxy_set_header X-Forwarded-Host $host:$server_port; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # WARNING: up timeout to 300s for Synthese downloading (See bug ) # Set timeout like Gunicorn in GeoNature config/settings.ini file proxy_read_timeout 300s; proxy_connect_timeout 75s; proxy_pass http://127.0.0.1:8000/;# ATTENTION : bien mettre un slash final ! Sinon => 404 } # Alias for Export module location "/exports/schedules" { alias /home/geonat/www/geonature/backend/static/exports/schedules; } location "/exports/users" { alias /home/geonat/www/geonature/backend/static/exports/usr_generated; } ssl_certificate /etc/letsencrypt/live/<alias>.<domaine-sinp>/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/<alias>.<domaine-sinp>/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name geonature.<domaine-sinp>; ssl_certificate /etc/letsencrypt/live/<alias>.<domaine-sinp>/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/<alias>.<domaine-sinp>/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot return 302 https://<alias>.<domaine-sinp>$request_uri; } server { listen 80; listen [::]:80; server_name <alias>.<domaine-sinp> geonature.<domaine-sinp>; return 302 https://<alias>.<domaine-sinp>$request_uri; }
Deux types de pages de maintenance peuvent être affichées :
Le site bascule automatiquement en maintenance courte lorsque le dossier dist
contenant les fichiers du site générés par Angular n'existe pas.
La compilation de GeoNature via Angular supprime automatiquement ce dossier en début de compilation et le régénère à la fin.
Pour basculer le site GeoNature en maintenance longue, renommer le fichier maintenance.disable
en maintenance.enable
dans le dossier ~/www/maintenance/geonature/
.
mv ~/www/maintenance/geonature/maintenance.disable ~/www/maintenance/geonature/maintenance.enable
mv ~/www/maintenance/geonature/maintenance.enable ~/www/maintenance/geonature/maintenance.disable
Ce fichier doit simplement exister et avoir le bon nom. Il peut être vide.
Dans le cas d'une maintenance longue, vous pouvez souhaiter accéder au site pour visualiser le résultat de votre travail de maintenance :
/etc/nginx/sites-available/geonature.conf
afin de ne pas afficher la page maintenance. Les navigateurs présentant ces IP continueront d'accéder normalement au site.
maintenance_disable
au domaine principal hébergeant GeoNature. Vous pouvez passer par le "DevTools" de votre navigateur. Ce cookie doit contenir comme valeur un UUID spécifique. Si l'UUID coïncide avec celui indiqué dans le fichier /etc/nginx/sites-available/geonature.conf
la maintenance est désactivée.~/www/maintenance/geonatue/maintenance.enable
. Sa suppression désactive la page de maintenance.vi /etc/nginx/sites-available/geonature_maintenance.conf
server { listen [::]:443 ssl http2; # managed by Certbot listen 443 ssl http2; # managed by Certbot server_name <alias>.<domaine-sinp>; root /home/geonat/www/geonature/frontend/src/app/maintenance; ssl_certificate /etc/letsencrypt/live/<alias>.<domaine>/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/<alias>.<domaine>/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name geonature.<domaine-sinp>; ssl_certificate /etc/letsencrypt/live/<alias>.<domaine-sinp>/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/<alias>.<domaine-sinp>/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot return 302 https://<alias>.<domaine-sinp>$request_uri; } server { listen 80; listen [::]:80; server_name <alias>.<domaine-sinp> geonature.<domaine-sinp>; return 302 https://<alias>.<domaine-sinp>$request_uri; }