1.nginx的安装部署
2.常用命令
nginx -V 版本号查询
start nginx --启动
nginx -s stop --停止
3.启动tomcat(2台端口号不能重复)
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
4.Nginx配置
keepalive_timeout 65;
#负载均衡--默认轮询
upstream 集群名称(server_lib){
server xxx.xx.xx.149; #服务器列表
server xxx.xx.xx.150; #服务器列表
}
server{
listen 80;
server_name pam.wdhac.com.cn #hosts文件中配置
}
location / {
root html;
proxy pass http://server_lib; #反向代理--路由
}
nginx集群负载均衡几种方式:
1.默认轮询
ipstream server_lib{
server xxx.xx.xx.214;
server xxx.xx.xx.215;
}
2.指定权重
upstream backserver{
server xxx.xx.xx.214 weight=10;
server xxx.xx.xx.215 weight=10;
}
3.IP绑定ip_hash
upstream backserver{
ip_hash;
server xxx.xx.xx.214;
server xxx.xx.xx.215;
}
#HTTPS server
server{
listen 443 ssl;
server_name pam.wdhac.com.cn;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
ssl_session_cache shared:SLL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.html;
}
}