Nginx备忘录

    xiaoxiao2025-08-01  3

    1、查看进程 ps -ef | grep nginx ps aux | grep nginx(较为详细) 2、启动 /usr/local/nginx/sbin/nginx  -c /usr/local/nginx/conf/nginx.conf /opt/application/nginx/sbin/nginx -c /opt/application/nginx/conf/nginx.conf 3、停止 从容关闭:kill -QUIT ID 快速:kill -TERM ID 强制:kill -9 nginx 4、重启 kill -HUP ID 5、限制IP直接访问 if ( $host ~* "\d+\.\d+\.\d+\.\d+" ) {     return 400; } 6、跨域配置 add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; 7、流量限制 limit_rate_after 10M; limit_rate 1M; 8、访问者地理信息 GeoIP.dat GeoLiteCity.dat geoip_country /usr/geoip/GeoIP.dat; geoip_city /usr/geoip/GeoLiteCity; 9、常用模块 - Xslt模块:它是一个过滤器模块,可以借助一个或者多个Xslt模块转化XML响应 - Expires与ETag:都用于有效控制客户端缓存 -  X-Sendfile:处理文件下载相关 - WebDAV,Cook:添加--with-http_dav_module,ngx_http_userid_module模块 - 实现对响应体内容的替换:添加--with_http_sub_module模块 10、记录原始客户端IP(with-http_realip_module) set_real_ip_from 192.168.1.1/24;(1) set_real_ip_from 100.100.0.0/16; real_ip_header X-Real-IP;(3) (1)代表指定信任的地址,将会被替代为精确地IP地址 (2)real_ip header [X-Real-IP | X-Forwarded-For] 用于设置使用哪个头来替换IP地址,如果使用了X-Forwarded-For,那么该模块将会使用 X-Forwarded-For头中的最后一个IP地址来替换前端代理的IP地址 11、负载均衡使用upstream 12、配置SSL需使用openssl和openssl-devel 13、查看工作状态(with-http_stub_status_module) stub_status on; access_log off; 14、控制站点访问 allow 192.168.1.8 允许访问 deny 192.168.1.9 禁止访问 15、反向代理使用proxy_配置 16、压缩限速使用with-http_gzip_static_module 17、提供FTP下载 autoindex on; autoindex_exact_size on; autoindex: 1.启用或禁止自动,目录列表 2.有两个参数:on和off,默认值为off autoindex_exact_size: 1.设定目录列表文件显示格式,是否已精确的大小显示 2.有两个参数:on和off,默认值为on 3.精确显示是字节方式显示 , 取整显示是使用KB、MB、GB显示 autoindex_localtime: 1.是否在目录列表中以本地时间显示文件时间 2.有两个参数:on和off,默认值为off 3.它使用的是GMT时间 18、防止DDos攻击使用模块ngx_http_limit_req_module和ngx_http_limit_conn_module 19、限制并发limit_zone、limit_conn
    转载请注明原文地址: https://ju.6miu.com/read-1301275.html
    最新回复(0)