标签:资源 list factor localhost listen XML tomcat7 ryu 空格
在日常的工作中,需要用到nginx和tomcat,在这里记录一下具体的配置。
假设域名为 www.demo.com
server {
listen 80;
server_name www.demo.com demo.com; #多个域名之间用空格分开
access_log /web/wwwlogs/www.demo.com.log; #定义访问日志
error_log /web/wwwlogs/www.demo.com.log; #定义错误日志
index index.html index.htm index.jsp;
root /web/wwwroot/www.demo.com; #定义网站根目录
#error_page 404 /404.html;
#error_page 502 /502.html;
location ~ {
proxy_pass "http://www.demo.com:8080"; #设置代理path,注意端口一定要对应
proxy_set_header Host www.demo.com; #设置请求头
proxy_set_header X-Forwarded-For $remote_addr;
}
#设置静态资源访问规则
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ /\.ht {
deny all;
}
}
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase" />
</GlobalNamingResources>
<Service name="Catalina">
<!-- 定义tomcat http端口 -->
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt" />
</Host>
<!-- tomcat 虚拟主机配置 -->
<Host name="www.demo.com" appBase=""
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Alias>demo.com</Alias>
<Context path="" debug="0" docBase="/web/wwwroot/www.demo.com" reloadable="true" />
</Host>
</Engine>
</Service>
</Server>
标签:资源 list factor localhost listen XML tomcat7 ryu 空格
原文地址:https://www.cnblogs.com/huagee/p/9478873.html