server { listen 80; listen 443; server_name google.com www.google.com; #access_log /opt/nginx/logs/google.com.log; ######如果不需要加证书访问下面这些可以注销###### ssl on; ssl_certificate /opt/nginx/conf/cert/ssl/google.com.pem; ssl_certificate_key /opt/nginx/conf/cert/ssl/google.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_prefer_server_ciphers on; ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2; ######如果不需要加证书访问上面这些可以注销###### location / { root html/web-mobile-old/; index index.html index.htm; } location /xidadaisgood { alias html/web-mobile/; index index.html index.htm; } ### 这段脚本一定要加到server配置内部 ### ### 且if要在access_log前面 ### ### 否则set的变量将无法引用 ### if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") { set $year $1; set $month $2; set $day $3; } ### /opt/nginx/logs 记得加 777 权限 ### ### chmod 777 /opt/nginx/logs ### access_log /opt/nginx/logs/google.com-$year-$month-$day.log main; error_log /opt/nginx/logs/error.log; ### vim /etc/crontab # 设置定时任务自动生成日志 ### ### 每天凌晨两点自动执行这个脚本 ### ### 00 2 * * * root /opt/sh/ShanChu.sh ### ### 删除日志脚本在 /opt/ziyuan/Shell/YuMing/ShanChu.sh ### }