批量创建config文件

559 人阅读
分类:
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
#!/bin/bash
sslPath="/usr/local/nginx/ssl"
 
creat_file() {
    cat >/etc/nginx/conf.d/$1.conf<<EOF
server {
        listen      80;
        listen      443 ssl;
        server_name $1 www.$1;
        ssl_certificate         /usr/local/nginx/ssl/$1.pem;
        ssl_certificate_key     /usr/local/nginx/ssl/$1.key;
        access_log              /var/log/nginx/pzhan_access.log main;
        error_log               /var/log/nginx/pzhan_error.log;
        if (\$scheme = http) {
                rewrite ^(.*)$  https://$host$1 permanent;
        }
        location / {
                root /data/html/pzhan-loading-page;
                index index.htm index.html;
        }
}
EOF
}
cat /etc/nginx/conf.d/domain | while read line
do
    arry=($line)
    s_domain=${arry[0]}
    creat_file $s_domain
done
==============================================================
#!/bin/bash
sslPath="/usr/local/nginx/ssl"
 
creat_file() {
    cat >/etc/nginx/conf.d/share_$1.conf<<EOF
        server {
        listen 80;
            listen 443 ssl;
            server_name $1 www.$1;
            ssl_certificate $sslPath/$1.pem;
            ssl_certificate_key $sslPath/$1.key;
        return 301 https://$2;
        }
EOF
}
cat /etc/nginx/conf.d/domain_map | while read line
do
    arry=($line)
    s_domain=${arry[0]}
    d_domain=${arry[1]}
    creat_file $s_domain $d_domain
done


和博主交个朋友吧
关闭

博主小程序[微信扫一扫]

    发布篇幅
    • 文章总数:0
    • 原创:0
    • 转载:0
    • 译文:0
    文章分类
      文章存档
      阅读排行