Heim  >  Fragen und Antworten  >  Hauptteil

Nginx-Proxy-Tomcat-Problem

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

为情所困为情所困2713 Tage vor401

Antworte allen(1)Ich werde antworten

  • 仅有的幸福

    仅有的幸福2017-05-16 17:25:33

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

    Antwort
    0
  • StornierenAntwort