1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| cat > /etc/nginx/sites-available/$domain << EOF server { listen 80;
root /var/www/html; index index.html index.htm index.nginx-debian.html; server_name ${domain}; location / { try_files \$uri \$uri/ =404; }
if ( \$remote_addr != 127.0.0.1 ) { rewrite ^/(.*)$ https://${domain}/$1 redirect; }
access_log /var/log/nginx/${domain}.access.log; error_log /var/log/nginx/${domain}.error.log; } EOF
sed -i "s/\${domain}/$domain/g" /etc/nginx/sites-available/$domain
ln -s /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/
systemctl enable nginx --now systemctl stop nginx systemctl start nginx systemctl status nginx
|