欢迎光临
我们一直在努力

nginx 编译安装--支持https

服务器环境*************************************************************************
系统:CentOS 6.5
pcre-8.39
zlib-1.2.11
openssl-1.1.0c
nginx-1.10.2
**********************************************************************************

1、准备依赖包和必要组件

点击(此处)折叠或打开

  1. yum install gcc,gcc-c++
  2. pcre
  3.     cd /home/nginx/pcre-8.39
  4.     ./configure
  5.     make
  6.     make install
  7. zlib
  8.     cd zlib-1.2.11
  9.     ./configure
  10.     make
  11.     make install
  12. openssl
  13.     cd openssl-1.1.0c
  14.     ./config
  15.     make
  16.     make install

2、安装nginx

点击(此处)折叠或打开

  1. cd nginx1.10.2
  2.     ./configure confpath=/usr/local/nginx/nginx.conf \
  3.                     pidpath=/usr/local/nginx/nginx.pid \
  4.                     withhttp_ssl_module \
  5.                     withpcre=/home/nginx/pcre8.39 \
  6.                     withzlib=/home/nginx/zlib1.2.11 \
  7.                     withopenssl=/home/nginx/openssl1.1.0c \
  8.                     sbinpath=/usr/local/nginx
  9.     make
  10.     make install

3、配置nginx

点击(此处)折叠或打开

  1. gzip on; #开启压缩
  2.      location /zxq/ {
  3.          proxy_pass http://172.16.69.208:8080/;     #服务的主机地址端口
  4.          proxy_cookie_path / /zxq/;                 #配置session保持
  5.          proxy_set_header X-Real-IP $remote_addr;   #增加客户端实际IP地址
  6.          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #增加客户端实际IP地址
  7.     
  8.          access_log logs/access.logzxq;             #配置日志路径
  9.          keepalive_timeout 0;                       #http连接超时时间
  10.          proxy_read_timeout 120;
  11.          expires 5m;
  12.     }

其他参数:

proxy_connect_timeout
后端服务器连接的超时时间_发起握手等候响应超时时间

proxy_read_timeout
连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间)

proxy_send_timeout
后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据

4、相关指令

  1. #nginx -s reload #reload 配置文件
  2. #nginx -s reopen #重新打开日志文件等

5、其他配置
     404,50x的页面可以自定义,将做好的html文件放到nginx安装目录下的html文件夹内即可,
     具体配置

  1. error_page 404 /404.html;
  2.         # redirect server error pages to the static page /50x.html
  3.         #
  4.         error_page 500 502 503 504 /50x.html;
  5.         location = /50x.html {
  6.             root html;
  7.         }

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。