Nginx-tomcat框架
gcc --version
automake --version
autoconf --version
libtool --version
make --version
g++ --version yum install gcc-c++
zlib find /usr/ -name zlib.pc
cat /usr/lib64/pkgconfig/zlib.pc 可以查看版本
openssl openssl version -a
添加nginx用户和用户组
groupadd -r nginx
useradd -r -g nginx -d /home/nginx -m nginx
Cd /home/nginx
Mkdir local
Mkdir src
Cd /home/nginx/local
Mkdir tmp
下载源码https://www.openssl.org/source/
tar zxvf openssl-1.1.0j.tar.gz
./config
make && make install
查看版本rpm -qa pcre
下载源码
https://sourceforge.net/p/pcre/activity/?page=0&limit=100#5b97fdf6ee24ca3613e94893
unzip pcre-8.39.zip
cd pcre-8.39
./configure
make && make install
下载源码
https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/downloads/
Unzip nginx-goodies-nginx-sticky-module-ng-08a395c66e42.zip
mv nginx-goodies-nginx-sticky-module-ng-08a395c66e42 nginx-sticky-module
下载源码http://nginx.org/
tar zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2
./configure \
--prefix=/home/nginx/local/nginx \
--sbin-path=/home/nginx/local/nginx/sbin/nginx \
--conf-path=/home/nginx/local/nginx/conf/nginx.conf \
--pid-path=/home/nginx/local/nginx/nginx.pid \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/home/nginx/local/tmp/client/ \
--http-proxy-temp-path=/home/nginx/local/tmp/proxy/ \
--http-fastcgi-temp-path=/home/nginx/local/tmp/fcgi/ \
--http-uwsgi-temp-path=/home/nginx/local/tmp/uwsgi \
--http-scgi-temp-path=/home/nginx/local/tmp/scgi \
--with-openssl=/home/nginx/src/openssl-1.1.0j \
--with-pcre=/home/nginx/src/pcre-8.39 \
--add-module=/home/nginx/src/nginx-sticky-module \
make && make install
Cd /home/nginx/local/nginx/conf
Vi xxx.conf
server {
listen 80;
listen 443 ssl;
server_name localhost;
ssl on;
ssl_certificate /home/nginx/local/nginx/cert/xxx.pem;
ssl_certificate_key /home/nginx/local/nginx/cert/xxx.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ignore_invalid_headers off;
charset utf-8;
port_in_redirect on;
location / {
#root html;
#index index.html index.htm;
#proxy_ssl_session_reuse off;
proxy_set_header Host $http_host; #将头信息返回服务器
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
proxy_pass http://my_web;
}
}
Cd /home/nginx/local/nginx/conf
Vi nginx.conf 修改如下参数
user nginx;
worker_processes 8;
worker_connections 4096;
upstream my_web {
sticky expires=2m;
server xxx:9080 weight=1 max_fails=1 fail_timeout=10s;
server xxx:9081 weight=1 max_fails=1 fail_timeout=10s;
}
include xxx.conf;
去掉ssl认证
注释掉Connector port="443"作用域
添加
remoteIpHeader="x-forwarded-for" remoteIpProxiesHeader="x-forwarded-by" protocolHeader="x-forwarded-proto"/> 添加注释