您的位置:首页 > 运维架构 > Nginx

nginx相关(平滑升级包括回退,错误页个性化,访问控制,日志推送)

2020-01-11 13:43 99 查看

实验环境:145机器上,nginx12源码包平滑升级到nginx14,下面是具体步骤

解包,编译

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_sub_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_realip_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --with-file-aio --with-http_secure_link_module






如果新版不稳定,想回退到原来的版本就不要杀掉旧的主进程,然后就有以下回退步骤


2.错误页个性化




在145上配置上面的内容,实现负载均衡。
源码12默认的是轮询

以下是ip_hash的调度算法

出现172的页面,我们把172停掉

再次刷新页面,返回30的页面

我们再停掉30的httpd的服务,再次访问

完成
3.访问控制
主机访问控制(ngx_http_access_module)
172访问145

在145上做主机访问控制



这里有个测试就是关于拒绝所有和允许所有的效果


到172上测试访问145

再反过来应该就是拒绝了



证明同时存在allow all和deny all谁在上面最先匹配到就谁生效
nginx用户访问控制(ngx_http_auth_basic_module)



测试

因为验证需要返回图形,我们在win7里做好解析用游览器继续访问测试




完成
4.日志推送(日志模块ngx_http_log_module)


到172上看日志因为local7对应的是/var/log/boot.log日志下,我们访问145后看效果


这里我们自定义路径和管道
我们在145改nignx的配置文件

再到172上打开/etc/rsyslog.conf配置文件,添加下面这行

然后打开udp的514端口


在到145那保存退出,并重新加载日志

访问145,之前没有nginx.log文件,我们再次去172上查看就有了

  • 点赞
  • 收藏
  • 分享
  • 文章举报
Joker_Jack 发布了5 篇原创文章 · 获赞 0 · 访问量 469 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐