nginx配置文件模板

1.nginx.conf

worker_processes  1;
user nginx nginx;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    include extra/*.conf;
}

2.extra/xxx.conf

server {
        listen       80;
        server_name  blog.etiantian.org;
        location / {
            root   html/blog;
            index  index.html index.htm index.php;
        }
        location ~ .*\.(php|php5)?$ {
            root html/blog;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
}

3.负载均衡配置

upstream backend {
        server 10.0.0.8:80 weight=1;
        server 10.0.0.7:80 weight=1;
    }
    upstream static_backend {
        server 10.0.0.9:80 weight=1;
        server 10.0.0.10:80 weight=1;
    }

    server {
        listen       80;
        server_name  blog.etiantian.org;
        location / {
            proxy_pass http://backend;
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For $remote_addr;
        }
        location /wp-content/ {
            proxy_pass http://static_backend;
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For $remote_addr;
        }
}

4.静态web配置

server {
        listen       80;
        server_name  blog.etiantian.org;
        location / {
            root   html/blog;
            index  index.html index.htm index.php;
        }
}

5.全网备份模板(backup)

cat >/server/scripts/del.sh<<EOF
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
IP=\$(ifconfig eth1|awk -F "[ ]+" 'NR==2{print \$3}')
if
     [ \$(date +%w) -eq 2 ]
then
    time="\$(date +%F -d -1day)_week1"
else
    time="\$(date +%F -d -1day)"
fi
#rm
find /backup/ -type f -name "*.log" -mtime +1 |xargs rm -f &&\
find /backup/ -type f -name "*.md5" -mtime -1 |xargs md5sum -c  >/backup/\${time}.log  &&\
find /backup/ -type f -name "*{\$time}.tar.gz" -mtime +180 |xargs rm -f &&\
find /backup/ -type f ! -name "*week*" -mtime +7 |xargs rm -f
#mail
mail -s "\${time}.rsync.log" bj_keyan@163.com < /backu/\${time}.log
EOF
cat >/server/scripts/dabao<<EOF
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
IP=\$(ifconfig eth1|awk -F "[ :]+" 'NR==2{print \$3}')
BakPath=/backup
mkdir \$BakPath/\$IP -p
export RSYNC_PASSWORD=oldboy
if
     [ \$(date +%w) -eq 2 ]
then
    time="\$(date +%F -d -1day)_week%w"
else
    time="\$(date +%F -d -1day)"
fi
#打包
cd /&&\
tar -zcf  backup/\$IP/config.{\$time}.tar.gz  etc/rc.local server/scripts var/spool/cron/root &&\
tar -zcf   backup/\$IP/www.{\$time}.tar.gz application/nginx-1.16.0/html  &&\
tar -zcf  backup/\$IP/log.{\$time}.tar.gz  application/nginx-1.16.0/logs &&\
#md5
find /backup/ -type f -name "*{\$time}*.tar.gz" -mtime -1 |xargs md5sum  >/backup/\$IP/\$(date +%F -d -1day).md5 &&\
#推送
rsync -avz /backup/\$IP/*\${time}* rsync_backup@172.16.1.41::backup/\$IP &&\
#删除
find /backup/\$IP/ -type f -mtime +7|xargs rm -f
EOF

6.nfs共享服务(nfs)

cat >/server/scripts/dabao.sh<<EOF
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
IP=\$(ifconfig eth1|awk -F "[ :]+" 'NR==2{print \$3}')
BakPath=/backup
mkdir \$BakPath/\$IP -p
export RSYNC_PASSWORD=oldboy
if
     [ \$(date +%w) -eq 2 ]
then
    time="\$(date +%F -d -1day)_week%w"
else
    time="\$(date +%F -d -1day)"
fi
#打包
cd /&&\
tar -zcf  backup/\$IP/config.{\$time}.tar.gz  etc/rc.local server/scripts var/spool/cron/root &&\
tar -zcf   backup/\$IP/www.{\$time}.tar.gz data/  &&\
#md5
find /backup/ -type f -name "*{\$time}*.tar.gz" -mtime -1 |xargs md5sum  >/backup/\$IP/\$(date +%F -d -1day).md5 &&\
#推送
rsync -avz /backup/\$IP/*\${time}* rsync_backup@172.16.1.41::backup/\$IP &&\
#删除
find /backup/\$IP/ -type f -mtime +7|xargs rm -f
EOF
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容