http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream tomcat-travel{
server 192.168.16.115:8080 ; # 3 配置被代理服务器的ip和端口
#这里可以配置多个被代理服务器的IP和端口,实现负载均衡
# server 192.168.16.115:8081;
# server 192.168.16.115:8082 weight=2; # weight 权重 默认为1;修改为2 后访问的次数增加
}
server {
listen 80;
server_name www.testnginx.com; # 1 访问这个IP时,会去找 proxy_pass
location / {
# root html;
# 这里添加
proxy_pass http://tomcat-travel; # 2 这里会去找对应的主机
index index.html index.htm;
}
#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;
}
}
./nginx -s reload