- Nginx upstream timed out 10060
错误信息 upstream timed out (10060: A connection attempt failed because the connect
- Nginx使用Basic Auth认证做资源访问限制
生成密码 使用OpenSSL生成密码。如下:生成密码为123456的密文。 openssl passwd -crypt 123456 用户名密码文件 文件中用户
- Nginx解决前端CORS跨域问题
问题描述 Access to XMLHttpRequest at 'http://localhost:8080/test' from origin 'http
- Nginx查看已安装模块
-V 只能看到编译时指定的模块。 nginx -V auto/options Nginx安装目录中的auto目录下的options含有编译时指定的模块,可查看。
- Nginx使用X-Accel-Redirect实现静态文件下载的统计、鉴权、防盗链、限速等
需求 统计静态文件的下载次数; 判断用户是否有下载权限; 根据用户指定下载速度; 根据Referer判断是否需要防盗链; 根据用户属性限制下载速度; X-A
- nginx: [emerg] unknown directive "if($request_uri" in
错误 nginx: [emerg] unknown directive "if($request_uri" in 解决 if与($间需要有空格。 例如: if
- Nginx日志按天生成
无需借助logrotate等日志处理工具。 配置 http { log_format main '$remote_addr - $remote_us
- Nginx配置静态文件404(root与alias区别)
location /test/ { root /home/test; } 当url访问/test/1.png时会去/home/test/test/目录下
- Nginx开启HTTP2.0
前置条件 编译Nginx所用的OpenSSL版本必须在1.0.2e及以上 安装或升级OpenSSL可参考 编译安装Nginx并指定OpenSSL可参考
- Nginx编译安装
下载解压 wget http://nginx.org/download/nginx-1.16.1.tar.gz tar -zxvf nginx-1.16.1.t
- Nginx编译安装时提示the HTTP gzip module requires the zlib library
现象 若在“./configure”后方加入了“--with-http_gzip_static_module”(添加gzip压缩模块)提示以下错误: ./con
- Linux之CentOS yum安装Nginx
添加nginx源 方法一 sudo vim /etc/yum.repos.d/nginx.repo 插入内容 Centos6[nginx] name=ng
- Nginx配置之屏蔽某IP访问
查看Nginx日志中ip访问次数awk '{print $1}' access.log |sort |uniq -c|sort -n结果:42 222.64.1
- Nginx配置之开启状态检查
查看是否安装所需模块--with-http_stub_status_modulenginx -V如若未安装改模块,需重新编译安装./configure --wi
- Nginx配置之开启Gzip压缩
配置可供参考 gzip on; gzip_min_length 1k; gzip_buffers 4 16k; #gzip_http_version 1.0;
- Nginx配置之解决413错误(Request Entity Too Large)
Failed to load resource: the server responded with a status of 413 (Request Ent
- Nginx配置之视频防盗链
查看Nginx安装的模块 nginx -V 如果没有安装secure_link模块,则需安装 ./configure --with-http_secure_li
- Nginx配置之图片防盗链
配置 location ~* ^/uploads/img/.*?\.(jpe?g|png|gif|svg)$ { valid_referers none
- Nginx配置之开启缓存过期时间
location ~ .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ {
- Nginx配置之PHP路径配置
80端口对应单个PHP服务server { listen 80; server_name localhost; root