-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdocker-nginx-ubuntu.sh
83 lines (68 loc) · 2.51 KB
/
docker-nginx-ubuntu.sh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
####################################################################################################
#### STAHHPP This is not a script, these are commands. Don't run as a script or I CHOP FINGERS! ####
####################################################################################################
## Install and do your main updates first whily setting up ssh
sudo apt update && sudo apt upgrade -y
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status numbered
sudo ufw delete 3
echo y | sudo ufw delete 3
sudo ufw allow from 10.0.0.88 to any port 22 proto tcp
sudo su
## Dependencies
sudo apt install net-tools apt-transport-https software-properties-common certbot git curl -y
## Docker Install Script
# https://docs.docker.com/engine/install/ubuntu/
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh
## Certbot
certbot certonly -d server.flacko.net
# 1
# y
# y
## Nginx Install https://hub.docker.com/_/nginx/
## https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-docker/
#non root (exit if root #)
mkdir -p /home/flacko/website/html
mkdir -p /home/flacko/website/nginx-conf
echo "<html><body><h1>My Website</h1></body></html>" > /home/flacko/website/html/index.html
nano /home/flacko/website/nginx-conf/default.conf
##########################################################################
## NGINX Configuration for /home/flacko/website/nginx-conf/default.conf ##
##########################################################################
server {
listen 80;
server_name server.flacko.net;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
server {
listen 443 ssl;
server_name server.flacko.net;
ssl_certificate /etc/letsencrypt/live/server.flacko.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/server.flacko.net/privkey.pem;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
##########################################################################
## Docker Run
sudo su
docker run -d \
-p 80:80 \
-p 443:443 \
--name my-nginx \
-v /home/flacko/website/html:/usr/share/nginx/html:ro \
-v /etc/letsencrypt/live/server.flacko.net/fullchain.pem:/etc/letsencrypt/live/server.flacko.net/fullchain.pem:ro \
-v /etc/letsencrypt/live/server.flacko.net/privkey.pem:/etc/letsencrypt/live/server.flacko.net/privkey.pem:ro \
-v /home/flacko/website/nginx-conf:/etc/nginx/conf.d:ro \
nginx
#Checking
netstat -plunt