Ngx基操
常规配置模板
#user www www;
worker_processes auto;
error_log /home/wwwlogs/nginx_error.log crit;
#pid /usr/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 655350;
events
{
use epoll;
worker_connections 655350;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml text/xml application/json;
gzip_vary on;
log_format access '$remote_addr - $remote_user [$time_local] $host '
'"$request" $status $body_bytes_sent $request_time '
'"$http_referer" "$http_user_agent" "$http_x_forwarded_for"'
'$upstream_addr $upstream_status $upstream_response_time' ;
#设置Web缓存区名称为cache_one,内存缓存空间大小为256MB,1天没有被访问的内容自动清除,硬盘缓存空间大小为30GB。
proxy_temp_path /home/proxy_temp_dir;
proxy_cache_path /home/proxy_cache_path levels=1:2 keys_zone=cache_one:256m inactive=1d max_size=30g;
server {
listen 80;
server_name _;
return 403;
}
include vhost/*.conf;
}用户认证
解决跨域
URL重写
域名跳转
域名镜像
防盗链
会话保持
动静分离
日志切割
location优先级
HTTPS 使用自颁发证书实现
基于HTTPS配置核心配置
根据页面不存在则自定义跳转
根据文件类型设置过期时间
根据域名自定义跳转
手机|PC端,作出相应的跳转
禁止访问目录|文件
添加模块--支持Websock模块
准备模块
查看Nginx已安装模块
备份源执行文件
下载源码编译
查看是否安装
添加模块--支持健康检查模块
缺陷?
准备模块
打补丁
重新编译
查看模块
如何使用?
验证
注意事项
参数详解
GIthub 地址
添加模块-支持国家城市模块
安装依赖 libmaxminddb
下载GeoIP源码
Nginx重新编译
下载GeoLite
启用 GeoIP
检查 GeoIP
内置变量
Last updated