nginx安装配置负载tomcatA和tomcatB
安装jdk
1>配置环境变量(etc/profile):
export JAVA_HOME=/usr/local/java/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
修改后source /etc/profile
2>解压tomcat修改server.xml对应的端口
安装nginx
1》
安装openssl库。
yum install -y openssl openssl-devel
需要安装gcc:yum install gcc-c++
安装 PCRE yum install -y pcre pcre-devel
安装zlib库 yum install -y zlib zlib-devel
2》进入目录编译:./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
3》编译make
4》安装:make install
5》运行./sbin/nginx
nginx.conf配置文件:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
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"';
access_log /usr/local/nginx/filelog/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
upstream lxstest{
server 127.0.0.1:8080;
server 127.0.0.1:8081;
}
#gzip on;
server {
listen 80;
server_name xiaoqi.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
#listen 80 default backlog=2048;
listen 443 ssl;
server_name xiaoqi.com;
#证书文件名称
ssl_certificate cert/nginx.pem; #你自己的证书
ssl_certificate_key cert/nginx.key;
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;
charset UTF-8;
access_log /usr/local/nginx/filelog/myweb_access.log;
error_log /usr/local/nginx/filelog/myweb_error.log;
client_max_body_size 75M;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://lxstest;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}