![简单代理反向Apache-Tomcat](https://linux22.com/image/668944/%E7%AE%80%E5%8D%95%E4%BB%A3%E7%90%86%E5%8F%8D%E5%90%91Apache-Tomcat.png)
我的目的很简单,我想输入 example.com 并重定向到 example.com:8080/myapp
example.com:8080/myapp 是一个 java/tomcat 应用程序。
<VirtualHost *:80>
ServerName example.com
ProxyPass / example.com:8080/myapp/
ProxyPassReverse / example.com:8080/myapp/
ProxyRequests Off
RewriteEngine on
RewriteRule ^(/.*) example.com:8080/myapp/$1 [P]
<Proxy example.com:8080/myapp*>
Order deny,allow
Allow from all
</Proxy>
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
结果是当我输入http://example.com它被重定向到 example.com:8080/myapp/myapp
我的 Tomcat 文件 server.xml 有以下指令:
Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
proxyPort="80" proxyName="example.com"
我没有看到什么?
答案1
- 应该
rewriterule
不需要了。删除它怎么样? 您可以将虚拟主机修改为:
<Location / > ProxyPass http://localhost:8080/myapp ProxyPassReverse http://localhost:8080/myapp </Location>
(我删除了结尾的斜杠)