1、添加nginx第三方yum源
cat > /etc/yum.repos.d/nginx.repo <<EOF[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/enabled=1gpgcheck=0EOF2、接下来就可以用yum来安装nginx了yum install nginx -y 3、 新建rewrite规则[root@test ~]# cat /etc/nginx/conf.d/test.conf upstream app_test { server 127.0.0.1:8080 weight=1 max_fails=2 fail_timeout=30s; } server { listen 80; server_name jeffery.com; rewrite ^/$ http://jeffery.com/index.jsp permanent; location / { root html; index index.jsp index.php index.html index.htm; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://app_test; } } 接下来就可以通过80端口来访问tomcat应用了可能你会问 为什么不直接修改server.xml文件中的端口号呢?在现实 生活中tomcat可能会交予多人来维护,Linux默认不通用户无法开启1024一下端