将项目打包后,我们执行下面的命令
java -jar test.jar --server.port=8001
java -jar test.jar --server.port=8002
接下来我们打开nginx的配置文件
http{upstreamupstream_name{server192.168.0.28:8001;server192.168.0.28:8002; }server{listen8080;server_namelocalhost;location/ {proxy_passhttp://upstream_name;proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; } }}