====== Configurer Nginx pour UsersHub ====== * Créer un fichier de config Nginx pour TaxHub : ''vi /etc/nginx/sites-available/taxhub.conf'' * Y placer le contenu suivant : server { listen 80; listen [::]:80; server_name usershub.; location / { 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; proxy_pass http://127.0.0.1:5001/;# ATTENTION : bien mettre un slash final ! Sinon => erreur 404 } } * Créer un lien depuis les sites actifs : ''cd /etc/nginx/sites-enabled/ ; ln -s ../sites-available/usershub.conf usershub.conf'' * Tester la config et relancer Nginx si OK : ''nginx -t && nginx -s reload'' * Tester l'URL http://usershub./ qui doit afficher une erreur 502 si le serveur Gunicorn de TaxHub n'est pas lancé. * Vérifier les services supervisés par Supervisor : ''supervisorctl status'' * Démarrer le service UsersHub : ''supervisorctl start usershub2'' * Arrêter le service UsersHub : ''supervisorctl stop usershub2'' * Installer un certificat SSL via Certbot (Letsencrypt) : ''certbot --nginx -d usershub.'' * Ex. SINP PACA : '' certbot --nginx -d usershub.silene.eu '' * Ex. SINP AURA : certbot --nginx \ -d gestion.biodiversite-aura.fr -d usershub.biodiversite-aura.fr \ -d gestion.biodiversite-aura.com -d usershub.biodiversite-aura.com \ -d gestion.biodiversite-aura.eu -d usershub.biodiversite-aura.eu \ -d gestion.biodiversite-aura.net -d usershub.biodiversite-aura.net \ -d gestion.biodiversite-aura.org -d usershub.biodiversite-aura.org \ -d gestion.biodiversite-auvergne-rhone-alpes.com -d usershub.biodiversite-auvergne-rhone-alpes.com \ -d gestion.biodiversite-auvergne-rhone-alpes.eu -d usershub.biodiversite-auvergne-rhone-alpes.eu \ -d gestion.biodiversite-auvergne-rhone-alpes.net -d usershub.biodiversite-auvergne-rhone-alpes.net \ -d gestion.biodiversite-auvergne-rhone-alpes.org -d usershub.biodiversite-auvergne-rhone-alpes.org \ -d gestion.observatoire-biodiversite-auvergne-rhone-alpes.com -d usershub.observatoire-biodiversite-auvergne-rhone-alpes.com \ -d gestion.observatoire-biodiversite-auvergne-rhone-alpes.eu -d usershub.observatoire-biodiversite-auvergne-rhone-alpes.eu \ -d gestion.observatoire-biodiversite-auvergne-rhone-alpes.fr -d usershub.observatoire-biodiversite-auvergne-rhone-alpes.fr \ -d gestion.observatoire-biodiversite-auvergne-rhone-alpes.net -d usershub.observatoire-biodiversite-auvergne-rhone-alpes.net \ -d gestion.observatoire-biodiversite-auvergne-rhone-alpes.org -d usershub.observatoire-biodiversite-auvergne-rhone-alpes.org * Répondre : 2 * Tester ensuite la redirection auto de HTTP vers HTTPS : http://usershub./ -> doit redirigé vers HTTPS automatiquement * Tester la configuration SSL : https://www.ssllabs.com/ssltest/analyze.html?d=usershub. * Tester l'URL https://usershub./ * La config finale : server { listen 443 ssl http2; # managed by Certbot listen [::]:443 ssl http2; # managed by Certbot server_name usershub.; location / { 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; proxy_pass http://127.0.0.1:5001/;# ATTENTION : bien mettre un slash final ! Sinon => erreur 404 } ssl_certificate /etc/letsencrypt/live/usershub./fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/usershub./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 80; listen [::]:80; server_name usershub.; return 302 https://$host$request_uri; }