修改nginx 的配置文件/etc/nginx/nginx.conf
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
# 负载均衡模块,负责网站的负载均衡功能和节点的健康检查
# 实例中127.0.0.1:8080和8081分别是两个tomcat的ip地址和访问端口号
upstream myservers{
server 127.0.0.1:8080 weight=1;
server 127.0.0.1:8081 weight=1;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
# 请求转发模块,将请求转发到指定的服务器上
proxy_pass http://myservers;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
修改tomcat的访问端口: ./conf/server.xml
将其中一个tomcat的以下两个端口分别该为:8006,8081,另一个tomcat的配置文件使用默认值,即仍是
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="8081" protocol="HTTP/1.1"
.../>