我在将Apache配置为反向代理时遇到问题,因此我可以从URL到我的Tomcat应用程序中删除端口号。我已经完成了几个教程,但我总是遇到同样的问题:Apache似乎传递了HTML但没有底层的程序化部分和样式。 (对不起,我能说出最好的描述。下面的屏幕截图说明我的意思)。
以下是我通过端口8080直接访问Tomcat时看到的内容:
但这是我在通过Apache转发时所看到的:
正如许多教程所暗示的那样,我已经启用了mod_proxy
,proxy_http
,proxy_html
和其他一些教程,但却无法解决我的问题。这是Apache读取的虚拟主机文件:
<VirtualHost *:80>
ServerAdmin XXXXX@XXX.COM
ServerName www.compastround.com
DocumentRoot /home/anthony/Public/
ErrorLog /var/log/apache2/music.compastround.com-error.log
CustomLog /var/log/apache2/music.compastround.com-access.log combined
ServerSignature Off
ProxyPass /music/ http://localhost:8080/subsonic-tomcat/
ProxyPassReverse /music/ http://localhost:8080/subsonic-tomcat/
<Directory /home/anthony/Public/>
Order allow,deny
Allow from all
Require all granted
Options FollowSymLinks
AllowOverride All
Options -Multiviews
</Directory>
</VirtualHost>
这是Tomcat的server.xml:
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<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 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="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
proxyName="www.compastround.com"
proxyPort="80" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
非常感谢任何帮助。提前谢谢。
答案 0 :(得分:0)
我的httpd-vhosts.conf ::
<VirtualHost *:80>
ServerAdmin 974984076@qq.com
ServerName XXXX
ServerAlias localhost
ProxyPass / balancer://cluster/ stickysession=JSESSIONID|jsessionid nofailover=Off
ProxyPassReverse / balancer://cluster/
ErrorLog "logs/lbtest-error.log"
CustomLog "logs/lbtest-access.log" common
<Proxy balancer://cluster>
BalancerMember ajp://XXX:XXX loadfactor=1 route=tomcat1
BalancerMember ajp://XXX:XXX loadfactor=2 route=tomcat2
</Proxy>
</VirtualHost>
我的tomcat servel.xml
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4" port="45564"
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4000"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=""/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
</Engine>
</Service>
答案 1 :(得分:0)
按照马克·托马斯的说法&#39;在评论中提出建议,我更改了我的虚拟主机文件,以便上下文路径相同,我的问题得到了解决。