我有一个子域test.example.com。我在端口8086的tomcat8.5中运行了一个java web应用程序。
在/opt/tomcat/conf/server.xml中,定义了如下所示的虚拟主机。
<Host name="canicarry.thehatapps.com" appBase="webapps/SecondAmendmentSupporters-0.2" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="canicarry_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>我有一个apache2 conf定义如下所示。/etc/apache2/sites-available/test.example.com.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
ServerName test.example.com
ServerAlias www.test.example.com.com
DocumentRoot /var/www/test.example.com/public_html
<Directory /var/www/test.example.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>在public_html中,.htaccess的定义如下所示。
RedirectPermanent / http://test.example.com:8086我的目标是能够在端口8086上点击myapp-02 tomcat web应用程序,就像so http://canicarry.thehatapps.com:8086一样。
我不知道出了什么问题,但我得到404。我似乎无法将http://canicarry.thehatapps.com:8086解析为运行在tomcat中的web应用程序。
任何帮助都将不胜感激。
编辑了
<VirtualHost canicarry.thehatapps.com/*:80>
ServerName canicarry.thehatapps.com
ProxyRequests Off
ProxyPass / ajp://localhost:8086/SecondAmendmentSupporters-0.2
ProxyPassReverse / ajp://localhost:8086/SecondAmendmentSupporters-0.2
</VirtualHost>当我输入http://canicarry.thehatapps.com:8086时,我就习惯于
http://104.238.96.249:8086/SecondAmendmentSupporters-0.2/
这是我的tomcat应用程序的完整url。但是,当我追加端点时,它不会解析。此外,url仍然应该是http://canicarry.thehatapps.com:8086。它不应该向tomcat应用程序实例显示完整的url。
例如,http://canicarry.thehatapps.com:8086/places应该从服务返回一个位置列表,但它不解析url。
发布于 2019-07-08 05:56:16
您的<VirtualHost *:80>正在告诉apache在端口80上监听。
如果希望通过端口8086公开应用程序,则需要将端口8086代理到tomcat服务器。您可以使用apache的ajp_proxy模块来完成这一任务。
<VirtualHost test.example.com:8086>
ServerName test.example.com
ProxyRequests Off
ProxyPass /examples ajp://127.0.0.1:8086/examples
ProxyPassReverse /examples ajp://localhost:8086/examples
</VirtualHost>详情见下面的文章
https://stackoverflow.com/questions/56796515
复制相似问题