批量创建config文件

534 人阅读
分类:
#!/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
    文章分类
      文章存档
      阅读排行