Nginx-Proxy-Tomcat-Problem
为情所困
为情所困 2017-05-16 17:23:33
0
1
399

Bei den folgenden beiden Optionen weiß ich nicht, ob meine Konfiguration falsch ist oder so. Nach der ersten Konfiguration verbraucht sie viele Ressourcen, insbesondere beim ersten Start. Die zweite kann nicht gestartet werden ist kein Problem, aber das zweite ist in Ordnung. Wenn ja, liegt ein Problem vor Tomcat

Ich besuche

http://kaipizhe.com 这个时候 request.getRequestURI(); 这个值是 /kaipizhe/ 而不是 / Ich besuche
http://kaipizhe.com/all/ 这个时候 request.getRequestURI(); 这个值是 /kaipizhe/all/ 而不是 /all/

Siehe diese Frage speziell: Linkbeschreibung



Option 1:

Konfiguration: Nginx

nginxserver
{
    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;
}

server.xml Konfiguration: Tomcat server.xml

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 2:

Konfiguration: Nginx

nginxserver
{
    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;
}

server.xml wird nicht geändert, d. h. Host wird nicht hinzugefügtTomcat server.xml 不修改,也就是不增加 Host

为情所困
为情所困

Antworte allen(1)
仅有的幸福

应该是tomcat的问题,看看tomcat启动日志里面有没有什么报错信息。

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!