随笔分类 - Nginx
摘要:## zabbix6.0 server端已经不支持centos7 了,故本文章以RockyLinux 9 演示 OS :Rocky Linux release 9.2 (Blue Onyx) Database: Mysql Web Server :Nginx RockyLinux下载地址:https
阅读全文
摘要:一、通过yum安装nginx 获取nginx的启动脚本(或直接复制我下面的脚本,只需要改变路径即可) /usr/lib/systemd/system/nginx.service 脚本内容如下: [Unit] Description=nginx - high performance web serve
阅读全文
摘要:[Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network-online.target remote-fs.target nss-lookup
阅读全文
摘要:Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验。它的最终目标是打造一个高效、稳定、安全、易用的Web平台。 官网:http://tengine.
阅读全文
摘要:一、ip_hash vim /etc/nginx/nginx.conf http { upstream websrvs { server 192.168.1.4:80; server 192.168.1.6:80; server 127.0.0.1:8080 backup; ip_hash; } }
阅读全文
摘要:第三方模块是对nginx 的功能扩展,第三方模块需要在编译安装nginx 的时候使用参数--add-module=PATH指定路径添加,有的模块是由公司的开发人员针对业务需求定制开发的,有的模块是开源爱好者开发好之后上传到github进行开源的模块,nginx支持第三方模块,需要重新编译源码才能支持
阅读全文
摘要:定义与后端服务器建立连接的超时时长,如超时会出现502错误,默认为60s,一般不建议超出75s proxy_connect_timeout time; 对后端服务器send,将请求发送给后端服务器的超时时长;默认为60s proxy_send_timeout time; 从后端服务器read,等待后
阅读全文
摘要:proxy_hide_header field; 用于隐藏后端服务器特定的响应首部,默认nginx在响应报文中不传递后端服务器的首部字段Date, Server, X-Pad, X-Accel等 测试访问: curl www.test.net/api/m.html -L -I HTTP/1.1 20
阅读全文
摘要:文件服务器:192.168.1.6 ll -h m.html -rw-r--r-- 1 root root 587K Jun 8 13:06 m.html 测试服务器:192.168.1.4 没开启缓存前测试访问 ab -c1000 -n 2000 www.test.net/api/m.html T
阅读全文
摘要:默认后端服务器只能看到是前端nginx调度器访问的本机 针对前端只有单个代理服务器的解决办法 一、修改调度机nginx的虚拟主机的配置文件 设定转发往后端主机的请求报文的请求首部的值; vim /etc/nginx/conf.d/test.conf server { listen 80; serve
阅读全文
摘要:一、Apache服务器上安装httpd yum install httpd -y 二、生成包含IP地址的新页面 echo 192.168.1.4 > /var/www/html/index.html 三、开启服务,并设置为开机自启动 systemctl start httpd systemctl e
阅读全文
摘要:ngx_http_referer_module模块: 用来阻止Referer首部无有效值的请求访问,可防止盗链valid_referers none|blocked|server_names|string ...;定义referer首部的合法可用值,不能匹配的将是非法值 none:请求报文首部没有r
阅读全文
摘要:通过用户发请求的变量 $request _filename location / { #当用户访问错误页面,自动跳转到首页 if ( !-e $request_filename ) { rewrite ^/(.*)$ https://www.test.com/ ; } } -e 判断是否存在, !-
阅读全文
摘要:测试环境下,采用自生成的证书和私钥 一、生成证书和私钥 1、进入certs这个目录,在这个目录下使用make 可以直接生成证书 cd /etc/ssl/certs 2、修改Makefile文件,去掉里面生成证书自动加密 vim Makefile %.key: umask 77 ; \ /usr/bi
阅读全文
摘要:一、下载vi语法高亮配置到 ~/.vim/syntax,如果不存在则创建该目录 mkdir /root/.vim/syntax -pv cd /root/.vim/syntax wget http://www.vim.org/scripts/download_script.php?src_id=14
阅读全文
摘要:return code [text]; #返回客户端指定的状态码和文本说明return code URL;return URL;停止处理,并返回给客户端指定的响应码(包括: 204, 400, 402 — 406, 408, 410, 411, 413, 416, 500 — 504),并对 301
阅读全文
摘要:ngx_http_rewrite_module模块:将用户请求的URI基于PCRE regex所描述的模式进行检查,而后完成重定向替换 一、使用if判断,通过return,将http跳转到https vim /etc/nginx/conf.d/test.conf server { listen 44
阅读全文
摘要:1、生成证书 cd /etc/pki/tls/certs/ make www.a.net.crt umask 77 ; \/usr/bin/openssl genrsa -aes128 2048 > www.a.net.keyGenerating RSA private key, 2048 bit
阅读全文
摘要:使用模块 ngx_http_gzip_module 用gzip方法压缩响应数据,节约带宽 一、启用或禁用gzip压缩 gzip on | off; 二、压缩比由低到高:1 到 9, 默认:1 gzip_comp_level level; 压缩比越高,越消耗CPU 三、匹配到客户端浏览器不执行压缩 g
阅读全文
摘要:yum服务器IP地址:192.168.1.9 测试服务器地址:192.168.1.4 一、安装搭建仓库所需软件 1、配置nginx 源 vim /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http
阅读全文