nginx反向代理 tomcat配置

tomcat server.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server-xml [
<!ENTITY vhost-localhost SYSTEM "file:///usr/local/tomcat/conf/vhost/localhost.xml">
<!ENTITY vhost-www.lin.com SYSTEM "file:///usr/local/tomcat/conf/vhost/www.lin.com.xml">
]>
<Server port="8006" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
<!--
  <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="8081" rmiServerPortPlatform="8082" />
-->
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="8080"
              protocol="org.apache.coyote.http11.Http11AprProtocol"
              connectionTimeout="20000"
              redirectPort="8443"
              maxThreads="1000"
              minSpareThreads="20"
              acceptCount="1000"
              maxHttpHeaderSize="65536"
              disableUploadTimeout="true"
              useBodyEncodingForURI="true"
              enableLookups="false"
              URIEncoding="UTF-8" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      &vhost-www.lin.com;
    </Engine>
  </Service>
</Server>


tomcat vhost配置:

<Host name="localhost" appBase="/data/wwwroot/default" unpackWARs="true" autoDeploy="true">
  <Context path="" docBase="/data/wwwroot/default/my-blog" reloadable="false" crossContext="true"/>

  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
    prefix="www.lin.com_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>


nginx反向代理配置:

server {
  listen 80;
  server_name 你的站点;
  access_log off;
  index index.html index.htm index.jsp;
  #error_page 404 /404.html;
  #error_page 502 /502.html;


  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    root 静态文件目录;
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    root 静态文件目录;
    expires 7d;
    access_log off;
  }
  location ~ /\.ht {
    deny all;
  }
  location ~ {
    proxy_pass http://127.0.0.1:8080;
    proxy_connect_timeout 300s;
    proxy_send_timeout 900;
    proxy_read_timeout 900;
    proxy_buffer_size 32k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_redirect off;
    proxy_hide_header Vary;
    proxy_set_header Accept-Encoding '';
    proxy_set_header Referer $http_referer;
    proxy_set_header Cookie $http_cookie;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

  }
}
                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                             
           



标签: lnmp java tomcat
2017.9.13   /   热度:1511   /   分类: java

发表评论:

©地球仪的BLOG  |  Powered by Emlog