-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx
59 lines (45 loc) · 1.23 KB
/
nginx
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
# Define some colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Get public IP address
IP_ADDRESS=$(curl -s ifconfig.me)
# Update and upgrade
apt-get update -y
apt-get upgrade -y
# Install nginx and zip
apt-get install -y nginx zip
# Create directories
mkdir -p /etc/nginx/cert
mkdir -p /var/www/html/.well-known/pki-validation
# Configure firewall
ufw allow 'Nginx Full'
ufw allow OpenSSH
echo "y" | ufw enable
# Configure nginx
cat << EOF > /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
# ssl_certificate /etc/nginx/cert/certificate.crt;
# ssl_certificate_key /etc/nginx/cert/private.key;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name $IP_ADDRESS;
# if (\$scheme = http) {
# return 301 https://\$server_name\$request_uri;
# }
location / {
}
}
EOF
# Restart nginx
service nginx restart
# Print message
echo -e "${RED}*N*O*T*E*S*${NC} remove # in ${GREEN}/etc/nginx/sites-enabled/default${NC} after cerificate installed to run in full https"
echo ""
echo ""