我正在 apache tomcat 上运行一个 spring MVC 项目,端口为 http://localhost:8080/project_name/。
我的依赖项在 80 端口上运行的 apache 系统中,对于这种情况,我需要将此 URL 运行为 http://localhost:80/project_name/
我正在为 apache 使用 XAMPP
Note: Tomcat should run on 8080 port only
我已经尝试在 httpd.conf
文件中添加 VirtualHost
<VirtualHost *:80/project_name/>
ProxyPreserveHost On
ProxyRequests Off
ServerName http://localhost/
ServerAlias http://localhost/
ProxyPass / http://localhost:8080/project_name/
ProxyPassReverse / http://localhost:8080/project_name/
</VirtualHost>
有人可以帮忙吗?
任何解决方案都是值得赞赏的
谢谢
最佳答案
我试过了
<VirtualHost *:80>
ServerName localhost
ProxyPass / http://localhost:8080/
</VirtualHost>
这工作正常我可以访问 http://localhost:8080/project_name
作为 http://localhost/project_name
但我无法访问资源(例如:http://localhost/resources/images/header-logo-mini.jpg
) 通过 apache 服务器
最后,我通过阅读这个 documentation 得到了解决方案
我的解决方案是
<VirtualHost *:80>
ServerName localhost
ProxyPass /project_name/ http://localhost:8080/project_name/
</VirtualHost>
感谢@Nic3500
谢谢大家
关于spring - 将tomcat重定向到本地系统中的apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56921521/