首先配置:nginx
# cd /etc/nginx/conf.d/ # cp default.conf tomcat.conf # nano tomcat.conf
请在tomcat.conf里输入:
server { listen 80; server_name mydomain.com; index index.jsp; root /usr/share/nginx/html/h5; location / { proxy_pass http://mydomain.com:8080; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
这里请注意:mydomain.com是你的域名,/usr/share/nginx/html/h5是你的项目路径,要与下面的tomcat对应起来.
其次,修改Server.xml
# nano /usr/local/tomcat/conf/server.xml
请修改如下:
<Host name="mydomain.com" appBase="/usr/share/nginx/html/h5" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="/usr/share/nginx/html/h5" debug="0" reloadable="false" crossContext="tr$ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
时间: 2024-11-10 19:37:10