首页 > 其他 > 详细

nginx反向代理模板

时间:2020-05-23 22:22:41      阅读:77      评论:0      收藏:0      [点我收藏+]

部署db代理机

1.手写server语句
vim /etc/nginx/conf.d/ip.conf
server {
	listen 80;
	server_name cs.ip.com;
	
	location / {
	proxy_pass http://10.0.0.52:80;
	proxy_set_header Host $host;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
}

2.修改nginx主配置文件,修改日志格式(选做)
vim /etc/nginx/nginx.conf 
log_format  main  ‘lbIP$remote_addr - 用户$remote_user 本地时间[$time_local] "请求的方法和协议$request" ‘
                      ‘状态码$status 响应字节数$body_bytes_sent "从哪来$http_referer" ‘
                      ‘"浏览器配置$http_user_agent" --- "$http_x_forwarded_for";
                      
3.使用scp命令依次推送db01上的 .conf文件                    
scp /etc/nginx/conf.d/ip.conf root@10.0.0.52:/etc/nginx/conf.d/
scp /etc/nginx/conf.d/ip.conf root@10.0.0.53:/etc/nginx/conf.d/                      
scp /etc/nginx/conf.d/ip.conf root@10.0.0.54:/etc/nginx/conf.d/

4.修改/etc/nginx/conf.d/ip.conf文件,代理相应的代理机
vim /etc/nginx/conf.d/ip.conf

5.启动nginx,并加入开机自启动
systemctl start nginx
systemctl enable nginx

6.域名解析
10.0.0.51 cs.ip.com

7.监控nginx日志
tailf /var/log/nginx/access.log

8.浏览器访问cs.ip.com

技术分享图片

nginx反向代理模板

原文:https://www.cnblogs.com/syy1757528181/p/12944252.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!