-
Notifications
You must be signed in to change notification settings - Fork 0
/
final_nginx_config.sh
executable file
·104 lines (75 loc) · 2.57 KB
/
final_nginx_config.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# nginx config with SSL
echo "" > /etc/nginx/sites-available/default.conf
cat <<EOT>>/etc/nginx/sites-available/default.conf
server {
listen 80;
server_name iphpo.com www.iphpo.com mail.iphpo.com;
return 301 https://\$host\$request_uri;
}
server {
listen 443 ssl http2 default_server backlog=256;
server_name iphpo.com www.iphpo.com mail.iphpo.com;
root /var/www/html;
access_log /var/log/nginx/default.access.log;
error_log /var/log/nginx/default.error.log error;
ssl_certificate /etc/letsencrypt/live/iphpo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/iphpo.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location ~ /.well-known {
allow all;
break;
}
location / {
index index.php index.html index.htm;
ModSecurityEnabled on;
ModSecurityConfig /etc/nginx/modsecurity.conf;
try_files \$uri \$uri/ /index.php\$is_args\$args;
}
}
EOT
# blog config
echo "" > /etc/nginx/sites-available/blog.conf
cat <<EOT>>/etc/nginx/sites-available/blog.conf
server {
listen 80;
server_name blog.iphpo.com;
return 301 https://\$host\$request_uri;
}
server {
listen 443 ssl http2;
server_name blog.iphpo.com;
root /var/www/blog;
access_log /var/log/nginx/blog/access.log;
error_log /var/log/nginx/blog/error.log error;
ssl_certificate /etc/letsencrypt/live/iphpo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/iphpo.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location ~ /.well-known {
allow all;
break;
}
location / {
index index.php index.html index.htm;
ModSecurityEnabled on;
ModSecurityConfig /etc/nginx/modsecurity.conf;
try_files \$uri \$uri/ /index.php\$is_args\$args;
}
location ~ .php\$ {
fastcgi_pass unix:/var/run/php71-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param SCRIPT_NAME \$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
include fastcgi_params;
}
}
EOT
systemctl restart nginx