tomcat - 为 Tomcat 设置 Apache2
问题描述
如何设置 Apache2 以访问托管在 Tomcat 8 上的 Spring REST API?这个可以吗?它似乎不起作用。
这是我的配置文件。它存储在可用站点下
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /springrest http://127.0.0.1:8932/
ProxyPassReverse /springrest http://127.0.0.1:8932/
</VirtualHost>
解决方案
如果那是您的整个配置文件,那么您没有足够的。您必须具有ServerName
参数才能使事情正常工作。您需要使用:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ProxyPreserveHost on
ProxyPass /springrest http://localhost:8932/
ProxyPassReverse /springrest http://127.0.0.1:8932/
ProxyTimeout 360
</VirtualHost>
该文件通常命名为www.example.com.conf
. 一旦你把它放进sites-available
去,你就需要运行sudo a2ensite www.example.com
然后sudo systemctl restart apache2
.
推荐阅读
- php - 如何添加动态 Wordpress 菜单?
- react-native - 通过排毒打开深层链接时出错
- puppeteer - 如何使用 puppeter 设置的扩展启动我的浏览器?
- orika - orika SourceCodeContext.getInstance StuckThreadMaxTime
- postgresql - PostgreSQL:错误:列“”不存在
- javascript - 如何将对象处理程序传递给 vue 组件
- sql-server - 为什么在我的递归 cte 中我发现重复的最后一条记录?
- kotlin - 片段内 RecyclerView 的 Kotlin OnItemClickListener
- python - Stop() gevent webserver 永远不会被调用
- laravel - 将 eloquent 查询构建器方法链接到 find()