编译安装

yum install zlib-devel -y

wget https://nginx.org/download/nginx-1.15.12.tar.gz

tar -zxf nginx-1.15.12.tar.gz

./configure --with-stream --prefix=/usr/local/nginx-1.15.12

make && make install

cd /usr/local/ && ln -s nginx-1.15.12 nginx

启动脚本

cat > /etc/systemd/system/nginx.service <<EOF

[Unit]

Description=nginx proxy

After=network.target

After=network-online.target

Wants=network-online.target

[Service]

Type=forking

ExecStartPre=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf -p /usr/local/nginx -t

ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf -p /usr/local/nginx

ExecReload=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf -p /usr/local/nginx -s reload

PrivateTmp=true

Restart=always

RestartSec=5

StartLimitInterval=0

LimitNOFILE=65536

[Install]

WantedBy=multi-user.target

EOF

配置文件

[root@wsjy-proxy01 conf]# cat nginx.conf
worker_processes 1; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; sendfile on;
keepalive_timeout 65; upstream wsjy-proxy {
hash $remote_addr consistent;
server 10.101.99.121:30080;
server 10.101.99.122:30080;
server 10.101.99.123:30080;
} server {
listen 80;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://wsjy-proxy;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_redirect off;
}
access_log logs/http-proxy-80.log main; } }

多级代理配置

重点需将 http_host 变量传递至后端,否则可能到第二级代理会找不到资源。

proxy_set_header Host $http_host;

proxy_set_header Connection close;

nginx 多级7层代理安装配置的更多相关文章

  1. 【转】Nginx服务器的反向代理proxy_pass配置方法讲解

    [转]Nginx服务器的反向代理proxy_pass配置方法讲解 转自:http://www.jb51.net/article/78746.htm 就普通的反向代理来讲Nginx的配置还是比较简单的, ...

  2. nginx启用TCP反向代理日志配置

    Nginx使用TCP反向代理日志配置不同于http 修改nginx配置文档/usr/local/nginx/conf/nginx.conf 设置日志格式 stream { log_format pro ...

  3. Nginx实现七层负载均衡配置指导

    本文描述了如何使用Nginx实现在应用层实现7层负载均衡功能,Nginx支持虚拟主机,可以按照轮询,IP哈希,URL哈希,权重方式对后端服务器做负载均衡,还支持后端服务器健康检查功能.废话不多说,详细 ...

  4. FastDFS分布式文件系统&Nginx负载均衡最小环境安装配置[超级详解]

    1.背景 FastDFS 是一款开源的.分布式文件系统(Distributed File System),由淘宝开发平台部资深架构师余庆开发.该开源项目的主页是 http://code.google. ...

  5. nginx的stream反向代理mysql配置

    这里主要记录一下nginx的负载代理stream模块,首先编译的时候需要加上--with-stream, 就像这样 然后nginx.conf里面的配置是在http选项上面加上 #Mysql Rever ...

  6. linux下nginx、php和mysql安装配置

    一.安装nginx 安装nginx yum install -y epel-release yum install nginx -y 查看nginx软件包包括了哪些文件 rpm -ql nginx 启 ...

  7. Nginx服务器的反向代理proxy_pass配置方法讲解

    Nginx的配置还是比较简单的,如:   1 2 3 4 location ~ /* { proxy_pass http://127.0.0.1:8008; } 或者可以   1 2 3 4 loca ...

  8. Linux下 nginx + 最新版php5.5 安装配置详解

    1.nginx的安装: 首先nginx的安装需要依赖最基础的三个包,这里面我们不设计更多的扩展模块,只是安装最基础的三个包, zlib 此包主要是对http内容进行gzip压缩,减少网络传输流量 PC ...

  9. Nginx技术研究系列3-OpenResty安装配置

    上两篇中介绍了: Ngnix技术研究系列1-通过应用场景看Nginx的反向代理 Ngnix技术研究系列2-基于Redis实现动态路由 发现,应该加一篇OpenResty的安装部署说明,方便大家按图索骥 ...

随机推荐

  1. luogu P5290 [十二省联考2019]春节十二响 优先队列_启发式合并

    思维难度不大,在考上上写的启发式合并写错了,只拿了 60 pts,好难过QAQ 没什么太难的,在考场上想出链的部分分之后很容易就能想到正解.没错,就是非常短的启发式合并.注意一下,写的要漂亮一点,否则 ...

  2. 路飞学城Python-Day35

    08-初识SQL语句 数据库客户端操作的内容(增查改删): 1.操作数据库 操作数据库 增(本质上就是创建一个本地文件夹) create database db1 charset utf8; 查 查看 ...

  3. 服务器搭建域控与SQL Server的AlwaysOn环境过程(五)配置异地机房节点

    0 引言 注意点1 注意异地节点最好至少有2个AG节点,否则在本地节点进行手动故障转移的时候会出现仲裁警告,提示WSFC集群有脱机危险 在异地节点只有一个的情况下,虽然Windows2012R2有动态 ...

  4. IOS - [UIDevice currentDevice] name/model/localizedMode/systemName/systemVersion...../userInterfaceIdiom

    + (UIDevice *)currentDevice; @property(nonatomic,readonly,retain) NSString    *name;              // ...

  5. freeswitch 编码协商

    编辑 /usr/local/freeswitch/conf/sip_profiles/internal.xml 添加注释     <param name="inbound-zrtp-p ...

  6. django-10-中间件和上下文管理器

    <<<中间件的引入>>> 用户<->中间件<->url->视图  在app目录里面 middleware.py  (1)中间件就是一个 ...

  7. SpringBoot+Maven聚合多项目打包成jar

    已我最近自己在玩的一个DEMO为例 taosir为pom.xml,其他子项目均为其modules,且为jar项目 eureka为注册中心.workflow为提供者.entrance为调用方 entra ...

  8. 【BZOJ 1433】[ZJOI2009]假期的宿舍

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把每个人都分为左边和右边两个人 xi,yi 如果第i个人不回家或者是外校学生 那么它可以和他认识的人连一条容量为1的边(前提是这个认 ...

  9. java中的hachcode方法

    哈希表这个数据结构想必大多数人都不陌生,而且在很多地方都会利用到hash表来提高查找效率.在Java的Object类中有一个方法: public native int hashCode(); 根据这个 ...

  10. Eclipse删除多余工作空间

    选择perferences-->General -->Startup and Shutdown-->workspace-->选择多余的工作空间 -> remove -&g ...