nginx.md 3.2 KB

% NGINX

Mode Maintenance

Fichier d'accueil

<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Site en Maintenance</title>
</head>
<body>
    <h1>Site en Maintenance</h1>
    <p>Merci de revenir plus tard !</p>
</body>
</html>

Configuration

Ajouter ce bloc:

	###### MAINTENANCE ######
	#Changer la valeur de  maintenance a on ou off (decommenter/commenter la seconde ligne)
	#set $maintenance off;
	set $maintenance on;

	if ($remote_addr ~ (83.193.14.206)) {
		set $maintenance off;
	}
	if ($maintenance = on) {
		return 503;
	}

	location /maintenance {
	}

	error_page 503 @maintenance;
	location @maintenance {
		root /var/www/maintenance ;
		#rewrite  ^(/images/logo.png)$ /images/logo.png break;
		rewrite  ^(.*)$ /index.html break;
	}
	###### FIN MAINTENANCE ######

Par exemple:

server{
        listen 443 ssl;

	# AJOUT DES CERTIFICATS
    ssl_certificate /etc/letsencrypt/live/garagepourtous.fr/fullchain.pem ;
	#/etc/letsencrypt/live/garagepourtous.fr/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/garagepourtous.fr/privkey.pem ;
	# /etc/letsencrypt/live/garagepourtous.fr/privkey.pem; # managed by Certbot
 
        server_name www.garagepourtous.fr garagepourtous.fr;
        root    /var/www/www.garagepourtous.fr;
        index     index.php index.html index.htm;
 
        access_log /var/log/nginx/fr.garagepourtous.access_log;
        error_log /var/log/nginx/fr.garagepourtous.error_log;
 
        # Security
        include global/security.conf;
 
	###### MAINTENANCE ######

    #ICI

	###### FIN MAINTENANCE ######

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }
 
    # PHP-FPM
    include global/php-fpm-redis.conf;
 
    # STATICS FILES
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }


}

Gestion des mots de passe et accès dans nginx

sudo sh -c "echo -n 'thomas.richard3:'
sudo sh -c "openssl passwd -apr1"

Éditer le fichier (par exemple /etc/nginx/.auth.allow)

Webographie

Yunohost