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作为用 ...
随机推荐
- maven根据不同的运行环境,打包不同的配置文件(转载)
使用maven管理项目中的依赖,非常的方便.同时利用maven内置的各种插件,在命令行模式下完成打包.部署等操作,可方便后期的持续集成使用. 但是每一个maven工程(比如web项目),开发人员在开发 ...
- SELECT LAST_INSERT_ID() 的使用和注意事项
SELECT LAST_INSERT_ID() 的使用和注意事项 尊重个人劳动成果,转载请注明出处: http://blog.csdn.net/czd3355/article/details/7130 ...
- POJ 2429 long long 质因数分解
GCD & LCM Inverse Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16206 Accepted: ...
- C语言函数的变参实用与分析
实现变参传递的关键是: 传入参数在内存中是连续分布的. #define va_list void* #define va_arg(arg, type) *(type*)arg; arg = (char ...
- CMDB资产管理系统开发【day26】:批准资产入库
刚才都是一条像内存,硬盘,网卡.多条的话如何操作 只有一条数据 下面的是有多条数据的 硬盘必须字段的验证 def __create_disk_component(self): disk_info = ...
- Stick footers布局总结
一.Sticky footers解释 在网页设计中,Sticky footers设计是最古老和最常见的效果之一,大多数人都曾经经历过.它可以概括如下:如果页面内容不够长的时候,页脚块粘贴在视窗底部:如 ...
- ZOJ 3556 How Many Sets I
How Many Sets I Time Limit: 2 Seconds Memory Limit: 65536 KB Give a set S, |S| = n, then how ma ...
- MSSQL DBcheck
--1.创建数据库. --create database MyDatabase; --删除数据库 --drop database MyDatabase; ----------------------- ...
- js获取屏幕高度宽度
获取各种屏幕的宽度和高度Javascript: 网页可见区域宽: document.body.clientWidth网页可见区域高: document.body.clientHeight网页可见区域宽 ...
- bzoj 3197 DP
这道题我们可以看成给定两个黑白树,可以修改其中一棵树的颜色,问最少修改多少颜色可以使两棵树同构. 首先我们知道在树的同构中树上最长链中点(如果是偶数的话就是中间两个点)是不变的,我们把这个点叫做树的重 ...