一、配置Tomcat中的Web项目
编辑Tomcat安装目录/conf/server.xml文件,在默认的Host后插入一个新的Host,代码如下:
<Host name="网站域名" appBase="" unpackWARS="true" autoDeploy="true"> <Context path="" docBase="Web项目在本机的存放位置" debug="0" reloadable="true" crossContext="true" /> </Host>
二、配置Nginx
1、进入Nginx安装目录(使用yum安装的Nginx为/etc/nginx)下的conf.d目录(低版本Nginx为conf目录)
2、新建一个.conf文件,内容如下:
server {
listen 80;
server_name 网站域名;location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}