\ server { listen 80; listen 443 ssl; server_name t.guangxiyisi.com; #access_log logs/t.guangxiyisi.com.log main; ######如果不需要加证书访问下面这些可以注销###### #ssl on; #ssl_certificate /opt/nginx/conf/cert/ssl/t.guangxiyisi.com.pem; #ssl_certificate_key /opt/nginx/conf/cert/ssl/t.guangxiyisi.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 / { proxy_pass https://api.telegram.org; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~* ^/bot { resolver 8.8.8.8; proxy_buffering off; proxy_pass https://api.telegram.org$request_uri; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /nginx_status { ### location /nginx_status: 这定义了一个新的location块,将会响应访问/nginx_status的请求 ## stub_status on; ### stub_status on;: 这启用了status模块 ### access_log on; ### access_log off;: 这关闭了对/nginx_status的访问日志记录 ### access_log /opt/nginx/logs/status-$year-$month-$day.log main; ### 单独记录日志 ### set_real_ip_from 0.0.0.0/0; ## 这是所有的IPV4IP全部放开 ### real_ip_header X-Forwarded-For; ### 这个也要加 ### allow 122.128.111.227; deny all; } ### Active connections: 当前活跃连接数。 ### server accepts handled requests: 总请求数。 ### Reading: 读取客户端的请求数。 ### Writing: 响应客户端的请求数。 ### Waiting: 等待客户端请求的请求数。 ### 访问链接: https://t.guangxiyisi.com/nginx_status ### ### 这段脚本一定要加到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/t.guangxiyisi.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 ### ### service crond restart 重启crontab ### ### /etc/init.d/cron restart 重启crontab ### ### 修改域名配置 ### ### sed -i s#t.guangxiyisi.com#google.com#g /opt/nginx/conf/conf.d/t.guangxiyisi.com.conf ### }