The following two solutions, I don’t know if my configuration is wrong or something. After the first configuration, it consumes a lot of resources, especially when starting Tomcat
for the first time, the basic one cannot be started. The second There is no problem with the second type, but there is a problem with the second type. If it is
I visit http://kaipizhe.com
At this time request.getRequestURI();
this value is /kaipizhe/
instead of /
When I visit http://kaipizhe.com/all/
this time request.getRequestURI();
the value is /kaipizhe/all/
instead of /all/
See this question specifically: link description
Option One:
Nginx
Configuration:
nginx
server { listen 80; server_name kaipizhe.com; root /usr/local/tomcat/webapps/kaipizhe; include none.conf; location / { proxy_pass http://localhost:8080/; proxy_cookie_path / /; 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_redirect http://localhost:8080/ http://kaipizhe.com/; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log /home/wwwlogs/kaipizhe.com.log kaipizhe.com; }
Tomcat
server.xml
Configuration:
xml
<Host name="kaipizhe.com" appBase="kaipizhe" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <alias>kaipizhe.com</alias> <Context docBase="/usr/local/tomcat/webapps/kaipizhe" path="/" reloadable="true" /> </Host>
Option II:
Nginx
Configuration:
nginx
server { listen 80; server_name kaipizhe.com; root /usr/local/tomcat/webapps/kaipizhe; include none.conf; location / { proxy_pass http://localhost:8080/kaipizhe/; proxy_cookie_path /kaipizhe /; 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_redirect http://localhost:8080/kaipizhe/ http://kaipizhe.com/; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log /home/wwwlogs/kaipizhe.com.log kaipizhe.com; }
Tomcat
server.xml
Do not modify, that is, do not add Host
仅有的幸福2017-05-16 17:25:33
It should be a problem with tomcat. Check the tomcat startup log to see if there is any error message.