gpt4 book ai didi

apache - Tomcat端口8080转80

转载 作者:行者123 更新时间:2023-11-28 22:19:33 31 4
gpt4 key购买 nike

我在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

Client内网关闭了8080端口,他想用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>

谁能帮帮我?里卡多

***** 解决方案 ******只有一个虚拟主机:

<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>

最佳答案

您需要在 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/

关于apache - Tomcat端口8080转80,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27151615/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com