统计指定某一天的PV数cat cn_net_javascript.access.log | sed -n '/22\/Jul\/2022/p' | wc -l 根据访问IP统计UVawk '{print $1}' cn_net_javascript.access.log | sort -n | uniq | wc -l 查看某一时间段的IP访问量(4-6点)grep "22/Jul/2022:0[4-6]" cn_net_javascript.access.log | awk '{print $1}' | sort | uniq -c| sort -nr | wc -l grep "22/J
### ssh连接远程服务器自动断开解决修改 debian 的 /etc/ssh/sshd_configClientAliveInterval 30 # 每隔多少秒,服务器端向客户端发送心跳ClientAliveCountMax 6 # 多少次心跳无响应之后,会认为Client已经断开systemctl reload 重新加载一下配置systemctl status sshd.service 查看状态systemctl start sshd.service 开启服务systemctl restart sshd.service 重启服务systemctl enable sshd.service
location /img/ { alias /var/www/image/; } 若按照上述配置的话,则访问/img/目录里面的文件时,ningx会自动去/var/www/image/目录找文件
njs 简介Nginx 是C语言开发的,很多人扩展 Nginx 的功能,并未使用 C 语言开发,更常见的是使用 Lua 扩展和定制 Nginx 服务。比较著名的是 OpenResty 使用 lua-nginx-module 模块运行 Lua 语言,并集成了大量精良的 Lua 库、第三方模块,可以方便地搭建能够处理超高并发、扩展性极高的 Web 服务。就像Atwood定律所描述一样,该来的又来了。现在最新版本的 Nginx 1.9.11+ 已经推出了 njs 模块,可以在 nginx 的配置中引入 JavaScript 脚本,从而实现一些更复杂的 nginx 配置功能。NJS 模块并不是运行一个
第一步,查看openssl 版本openssl version -a openssl 1.0.1以上的版本支持 TLS1.2,openssl 1.1.1以上的版本支持 TLS1.3。openssl版本满足条件,如不满足,需要重新编译安装。第二步,检查所有虚拟主机,修改所有虚拟主机的 ssl_protocols SSLv2 SSLv3 TLSv1; 修改成ssl_protocols TLSv1 TLSv1.1 TLSv1.2; Nginx 多个虚拟主机中,如果有一个使用第一行配置,就会导致浏览器提示“用于加载此网站的连接使用的是 TLS 1.0 或 TLS 1.1,这两个 TLS 版本都已
一、通过openssl命令自建证书1、创建私钥:openssl genrsa -out server.key 1024 2、证书请求:openssl req -new -out server.csr -key server.key 3、自签署证书:openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt 4、将证书变成浏览器支持的.p12格式openssl pkcs12 -export -clcerts -in server.crt -inkey server.key -out serve
1, 使用 htpasswd 生成 passfile 文件htpasswd 是 apache 实用工具的一部分,Nginx 的密码格式和 Apache 的一样。CentOS 下的生成方法:yum install -y httpd-tools # 安装 htpasswd -c -d /etc/nginx/pass_file username Debian 下的生成方法:sudo apt-get install apache2-utils sudo htpasswd -c /etc/nginx/.htpasswd admin 2,添加到 nginx 配置在 server 或者 local 下,添加
Nginx 会根据mime type告诉浏览器如何处理服务器返回的文件,是打开还是下载。默认的 default_type定义的是 default_type application/octet-stream;mime type 和文件扩展名的对应关系一般放在 mime.types这个文件里,然后用 include mime.types; 来加载mime.types文件里是用types指令来定义的文本:location /test { default_type text/html; return 200 'This is text!'; } JSON:location /test
网站中图片过大无法正常显示,通常显示一半,就提示502错误了,Nginx 错误日志代理提示:2021/05/19 16:28:35 [crit] 10976#0: *13 open() "/nginx_dir/proxy_temp/2/00/0000000002" failed (13: Permission denied) while reading upstream, client: 200.130.237.38, server: test.com, request: "GET /uploads/images/20210220/48a18881fa3b45781b512f2376c9bef
location 匹配~ #匹配一个正则表达式,区分大小写 ~* #匹配一个正则表达式,不区分大小写 ^~ #匹配普通字符,如果该选项匹配,只匹配该选项,不匹配别的选项,一般用来匹配目录 = #进行普通字符精确匹配 @ #"@" 定义一个命名的 location,使用在内部定向时,例如 error_page, try_files 演示:location = / { # 只匹配"/" } location / { # 匹配所有请求,长字符或者正则表达式会优先匹配 } location ^~ /images/ { # 匹配任何以 /images/ 开始的请求,并
微信联系我