-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
49 lines (48 loc) · 1.85 KB
/
setup
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
#!/bin/sh
sudo add-apt-repository ppa:certbot/certbot
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs npm nginx certbot python-certbot-nginx
sudo certbot certonly --standalone
sudo cat server { \
server_name $fqdn; \
root /www/data; \
location / { \
auth_basic 'Restricted Content'; \
auth_basic_user_file /etc/nginx/conf.d/.htpasswd; \
} \
location ~* \.io { \
proxy_set_header X-Real-IP $remote_addr; \
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
proxy_set_header Host $http_host; \
proxy_set_header X-NginX-Proxy false; \
proxy_pass http://localhost:1024; \
proxy_redirect off; \
proxy_http_version 1.1; \
proxy_set_header Upgrade $http_upgrade; \
proxy_set_header Connection "upgrade"; \
auth_basic 'Restricted Content'; \
auth_basic_user_file /etc/nginx/conf.d/.htpasswd; \
} \
listen [::]:443 ssl ipv6only=on http2; # managed by Certbot \
listen 443 ssl http2; # managed by Certbot \
ssl_certificate /etc/letsencrypt/live/$fqdn/fullchain.pem; # managed by Certbot \
ssl_certificate_key /etc/letsencrypt/live/$fqdn/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 { \
if (\$host = $fqdn) { \
return 301 https://\$host\$request_uri; \
} # managed by Certbot \
listen 80; \
listen [::]:80; \
server_name $fqdn; \
return 404; # managed by Certbot \
} > /etc/nginx/conf.d/mc.conf
sudo certbot --nginx
echo -n 'user1:' | sudo tee /etc/nginx/conf.d/.htpasswd
openssl passwd -apr1 | sudo tee -a /etc/nginx/conf.d/.htpasswd
# enter password here
sudo nginx -t
sudo nginx -s reload