1.下载安装nginx
yum install nginx
2.安装完成默认目录在/etc/nginx
3.进入/etc/nginx/conf.d目录创建一个tomcat_mynginx.conf文件,内容为:
server {
listen 80;
server_name *.tyzou.com;
location / {
proxy_pass http://localhost:8888;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
备注:测试是否配置正确:nginx -t
4.修改tomcat/conf/server.xml文件的启动端口
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
5.启动tomcat
./startup.sh
6.启动nginx
systemctl start nginx
备注:如果要配置多个tomcat,就在conf.d目录下多创建一个.conf文件吧!so easy!你学会了吗?