Nginx-1.6.3反向代理
源码安装nginx
cat /etc/redhat-release
uname -rm
yum install pcre-devel openssl-devel -y
rpm -qa pcre pcre-devel openssl openssl-devel
groupadd -g 888 nginx
useradd nginx -u 888 -g nginx -s /sbin/nologin -M
mkdir -p /server/tools
cd /server/tools
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3 --with-http_stub_status_module --with-http_ssl_module
make
make install
ln -s /application/nginx-1.6.3 /application/nginx
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx
ps -ef | grep nginx
lsof -i :80
curl 10.0.0.41
单节点池转发
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream www_server_pools {
server 172.16.1.13:80 weight=1;
server 172.16.1.14:80 weight=1; }
server {
listen 80;
server_name www.peterwang.cn;
location / {
proxy_pass http://www_server_pools;
include proxy.conf;
}
}
} vim /application/nginx/conf/proxy.conf proxy_set_header Host $host; #在请求头中加入host字段信息
proxy_set_header X-Forwarded-For $remote_addr; #在请求头中加入获取的客户端IP字段信息
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
#接收到错误状态码时,会将用户请求转发给正常工作的RS服务器
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
多节点池转发
1.根据URL worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream static_server_pools {
server 10.0.0.7:80 weight=1; }
upstream upload_server_pools {
server 10.0.0.8:80 weight=1; }
server {
listen 80;
server_name www.peterwang.org;
location /static/ {
proxy_pass http://static_server_pools;
include proxy.conf;
}
location /upload/ {
proxy_pass http://upload_server_pools;
include proxy.conf;
}
}
} vim /application/nginx/conf/proxy.conf proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k; 2.根据用户设备 worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream static_server_pools {
server 10.0.0.7:80 weight=1; }
upstream upload_server_pools {
server 10.0.0.8:80 weight=1; }
server {
listen 80;
server_name www.etiantian.org;
location / {
if ($http_user_agent ~* "MSIE")
{
proxy_pass http://static_server_pools;
}
if ($http_user_agent ~* "Firefox")
{
proxy_pass http://upload_server_pools;
}
include proxy.conf;
}
}
}
节点监控模块安装
#nginx_upstream_check_module是由淘宝技术团队开发的用于监控集群节点状态的模块。
cd /server/tools
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/master.zip
unzip master.zip
cd nginx-1.6.3
patch -p1 < ../nginx_upstream_check_module-master/check_1.5.12+.patch
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3 \
--with-http_stub_status_module --with-http_ssl_module --add-module=../nginx_upstream_check_module-master/
make
mv /application/nginx/sbin/nginx{,.ori}
cp ./objs/nginx /application/nginx/sbin/
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx -V cd /application/nginx
vim conf/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream www_server_pools {
server 10.0.0.7:80 weight=1;
server 10.0.0.8:80 weight=1;
check interval=3000 rise=2 fall=5 timeout=1000 type=http;
}
server {
listen 80;
server_name www.etiantian.org;
location / {
root html;
index index.html index.htm;
proxy_pass http://www_server_pools;
include proxy.conf;
}
location /status/ {
check_status;
access_log off;
} sbin/nginx -t
sbin/nginx -s stop
sbin/nginx
Nginx-1.6.3反向代理的更多相关文章
- 通过Nginx+tomcat+redis实现反向代理 、负载均衡及session同步
一直对于负载均衡比较陌生,今天尝试着去了解了一下,并做了一个小的实验,对于这个概念有一些认识,在此做一个简单的总结 什么是负载均衡 负载均衡,英文 名称为Load Balance,指由多台服务器以对称 ...
- nginx和tomcat实现反向代理、负载均衡和session共享
这类的文章很多,nginx和tomcat实现反向代理.负载均衡实现很容易,可以参照http://blog.csdn.net/liuzhigang1237/article/details/8880752 ...
- Nginx的安装及反向代理设置
因为项目的缘故,接触到了Nginx的安装和反向代理设置,和大家分享下. 一.Nginx的下载.安装cd /homewget http://nginx.org/download/nginx-1.0.5. ...
- nginx与apache配合反向代理技术1
序:最近在看Dimitri Aivaliotis的<Mastering Nginx>,刚好跆拳道课下班在路上看了反向代理服务器,准备在自己的博客VPS尝试一下 web代理服务器可以实现分布 ...
- Nginx插件之openresty反向代理和日志滚动配置案例
Nginx插件之openresty反向代理和日志滚动配置案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.openresty介绍 1>.Nginx介绍 Nginx是一款 ...
- Nginx 负载均衡和反向代理实践
nginx 以哪个配置文件启动 Nginx 负载均衡和反向代理实践 环境介绍 192.168.1.50 在这台主机上配置Nginx 的反向代理,负载均衡,和web1,web1使用的81号端口 1 ...
- 【架构师之路】Nginx负载均衡与反向代理—《亿级流量网站架构核心技术》
本篇摘自<亿级流量网站架构核心技术>第二章 Nginx负载均衡与反向代理 部分内容. 当我们的应用单实例不能支撑用户请求时,此时就需要扩容,从一台服务器扩容到两台.几十台.几百台.然而,用 ...
- Nginx应用-Location路由反向代理及重写策略 请求转发-URL匹配规则 NGINX Reverse Proxy
NGINX Docs | NGINX Reverse Proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ ...
- nginx基于TCP的反向代理
一.4层的负载均衡 Nginx Plus的商业授权版开始具有TCP负载均衡的功能.从Nginx 1.7.7版本开始加入的,现在变成了一个商业收费版本,想要试用,需要在官网申请.也就是说,Nginx除了 ...
- 使用nginx和tomcat配置反向代理和动静分离
背景 本人主修的编程语言是Java语言,因此最开始接触的Web开发也是JSP技术.使用Java开发的Web应用需要部署在专门的服务器程序上运行,比如Tomcat.但是一般很少会有人将Tomcat作为用 ...
随机推荐
- 【刷题】UOJ #171 【WC2016】挑战NPC
小 N 最近在研究 NP 完全问题,小 O 看小 N 研究得热火朝天,便给他出了一道这样的题目: 有 \(n\) 个球,用整数 \(1\) 到 \(n\) 编号.还有 \(m\) 个筐子,用整数 \( ...
- BZOJ2427:[HAOI2010]软件安装——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=2427 https://www.luogu.org/problemnew/show/P2515 现在 ...
- mmc驱动的读写过程解析
mmc io的读写从mmc_queue_thread()的获取queue里面的request开始. 先列出调用栈,看下大概的调用顺序, 下面的内容主要阐述这些函数如何工作. host->ops- ...
- Linux上安装Oracle11g
1.首先是挂盘 1.1 Linux硬盘挂载步骤:查看磁盘 先查看目前机器上有几块硬盘,查看命令有两种: 命令1:# fdisk –l 命令2:# dmesg | grep sd 其中:fdisk命令说 ...
- 中国MOOC_面向对象程序设计——Java语言_第2周 对象交互_秒计时的数字时钟
第2周编程题 查看帮助 返回 第2周编程题,在课程所给的时钟程序的基础上修改 依照学术诚信条款,我保证此作业是本人独立完成的. 温馨提示: 1.本次作业属于Online Judge题目,提交后由系 ...
- JavaScript中Unicode值转字符
在JavaScript中,将Unicode值转字符的方法: <!DOCTYPE html> <html> <head> <meta charset=" ...
- 洛谷P4135 作诗 (分块)
洛谷P4135 作诗 题目描述 神犇SJY虐完HEOI之后给傻×LYD出了一题: SHY是T国的公主,平时的一大爱好是作诗. 由于时间紧迫,SHY作完诗之后还要虐OI,于是SHY找来一篇长度为N的文章 ...
- maven工程pom.xml报Missing artifact net.sf.jasperreports:jasperreports:jar:6.2.0
有时maven工程的pom.xml报以下类型错误: Description Resource Path Location TypeMissing artifact net.sf.jasperrepor ...
- oracle 存储过程 技巧
我们在进行pl/sql编程时打交道最多的就是存储过程了.存储过程的结构是非常的简单的,我们在这里除了学习存储过程的基本结构外,还会学习编写存储过程时相关的一些实用的知识.如:游标的处理,异常的处理,集 ...
- 51Nod 1010 只包含因子2 3 5的数 | 预处理+二分
Input示例 5 1 8 13 35 77 Output示例 2 8 15 36 80 分析:将所有的只含有2 3 5因子的数打一个表保存在一个数组里,然后二分查找第一个>=数组里的数,输出 ...