-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·76 lines (53 loc) · 1.24 KB
/
setup.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
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
set -e
apt -y update && apt -y upgrade
apt -y install lsb-release
DISTRO=$(lsb_release -is | awk '{print tolower($0)}')
CODENAME=$(lsb_release -cs)
apt -y install curl gnupg
curl -O https://nginx.org/keys/nginx_signing.key && apt-key add ./nginx_signing.key && rm ./nginx_signing.key
echo "deb http://nginx.org/packages/$DISTRO/ $CODENAME nginx" >> /etc/apt/sources.list
apt -y update && apt -y install nginx
CURRENT_PID=$(cat /etc/nginx/nginx.conf | grep -oP "pid\s*\K[^;]*")
PID=${CURRENT_PID:-/tmp/nginx.pid}
cat << EOL > /etc/nginx/nginx.conf
pid $PID;
EOL
cat << 'EOL' >> /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
worker_rlimit_nofile 32384;
events {
worker_connections 4096;
multi_accept on;
use epoll;
}
http {
error_log off;
access_log off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 5;
reset_timedout_connection on;
server {
listen 80;
if ($host ~* ^(?!www\.).*$) {
return 301 http://www.$host$request_uri;
}
return 400;
}
}
stream {
resolver 8.8.8.8;
resolver_timeout 5s;
server {
listen 443;
ssl_preread on;
proxy_pass www.$ssl_preread_server_name:443;
}
}
EOL
nginx -s quit || true
nginx