我在Ubuntu14上安装了Apache2和Tomcat7
http://mysite.it/ -> Apache OK
http://mysite.it/phpmyadmin -> Apache OK, showing phpmyadmin
http://mysite.it:8080/myApp/ -> Tomcat OK, showing my Spring App
8080端口在客户端Intranet中关闭,他想使用http://mysite.it/myApp/ 。 我需要在Apache2中设置代理/反向代理
这就是我所做的:
aptitude update
aptitude -y upgrade
aptitude install -y build-essential
aptitude install -y libapache2-mod-proxy-html libxml2-dev
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_ajp
a2enmod rewrite
a2enmod deflate
a2enmod headers
a2enmod proxy_balancer
a2enmod proxy_connect
a2enmod proxy_html
a2enmod xml2enc
现在我应该修改/etc/apache2/sites-enabled/000-default.conf
当前(默认)版本为
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我试图添加这个片段,但没有运气
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass /myApp/ http://mysite.it:8080/
ProxyPassReverse /myApp/ http://mysite.it:8080/
ServerName mysite.it
</VirtualHost>
任何人都可以帮助我吗? 的Riccardo
*****解决方案****** 只有一个虚拟主机:
<VirtualHost *:*>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ProxyPass /myApp/ http://mysite.it:8080/myApp/
ProxyPassReverse /myApp/ http://mysite.it:8080/myApp/
ServerName mysite.it
</VirtualHost>
答案 0 :(得分:1)
您需要在ProxyPass目标的末尾包含上下文名称(myApp):
ProxyPass /myApp/ http://mysite.it:8080/myApp/
ProxyPassReverse /myApp/ http://mysite.it:8080/myApp/
而不是
ProxyPass /myApp/ http://mysite.it:8080/
ProxyPassReverse /myApp/ http://mysite.it:8080/