nginx+tomcat根本配置

nginx+tomcat基本配置

nginx1.10.2安装:http://youngbrick.iteye.com/blog/2336022

tomcat8安装:http://youngbrick.iteye.com/blog/2335305

nginx基本配置

 

修改nginx.conf 文件,只添加了3处:

 

[root@localhost /]#cd /usr/local
[root@localhost local]# vi ./nginx/conf/nginx.conf

 

http {
    #gzip  on;
    ############1###############
    upstream local_tomcat{
        这里是访问tomcat的端口
	server localhost:8080;
    }
    server {
        listen       80;
        ############2###############
        server_name  local_tomcat;
        location / {
            root   html;
            index  index.html index.htm;
            ############3###############
	    proxy_pass http://local_tomcat;
        }
xxxxxxxxxxxx略xxxxxxxxxxxxxxxx
    }
xxxxxxxxxxxx略xxxxxxxxxxxx
}

 

启动tomcat

[root@localhost local]# ./apache-tomcat-8.5.6/bin/startup.sh 

 

重启nginx

 

[root@localhost local]# ./nginx/sbin/nginx -s reload

 

 

开放80和443端口并重新加载:

 

[root@localhost local]# firewall-cmd --zone=public --add-port=443/tcp --permanent
success
[root@localhost local]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@localhost local]# firewall-cmd --reload

 查看开发的端口:

 

 

[root@localhost local]# firewall-cmd --zone=public --list-ports
443/tcp 80/tcp

 浏览器访问:http://serverip/

能看到页面跳转到tomcat首页,说明配置成功。

 nginx+tomcat根本配置