对于使用 tomcat-connector 实现 iis 与 tomcat 实现 80 端口共用的问题, 网上的信息异常混乱, 很多地方误人子弟, 浪费时间. 本文给出简明手册式的做法:
首先列出我们需要做的事项:
1, 下载 tomcat-connector 的 dll
2, 创建 2 个目录, 一个用于 iis 建立网站, 一个用于创建 jakarta 虚拟目录
3, 创建 3 个 properties 文件
4,iis 设置映射关系
下面简明说明:
1, 下载我就不说了, 在 tomcat官方完整可以下, 会得到 isapi_redirect.dll
下载地址: https://tomcat.apache.org/download-connectors.cgi
2, 创建 3 个 properties文件, 内容如下
2.1 isapi_redirect.properties
内容如下:
- # Configuration file for the Tomcat ISAPI Redirector
- # The path to the ISAPI Redirector Extension, relative to the website
- # This must be in a virtual directory with execute privileges
- extension_uri=/jakarta/isapi_redirect.dll
- # Full path to the log file for the ISAPI Redirector
- log_file=d:/temp/logs/isapi_redirect.log
- # Log level (debug, info, warn, error or trace)
- log_level=debug
- # Full path to the workers.properties file
- worker_file=d:/temp/workers.properties
- # Full path to the uriworkermap.properties file
- worker_mount_file=d:/temp/uriworkermap.properties
- 2.2 workers.properties
内容如下:
- workers.tomcat_home=D:/tomcat9/
- workers.java_home=C:/Program Files/Java/jre1.8.0_191/
- # 值可任意, 但需要与 uriworkermap.properties 配置保持一致, 不一致会导致空白页
- worker.list=jdart
- # 下面其他可以忽略, 系统都有默认值
- #worker.jdart.type=ajp13
- # 这是 tomcat 的访问域名或 IP
- #worker.jdart.host=127.0.0.1
- # 同 server.xml 配置一致
- #worker.jdart.port=8009
- 2.3 uriworkermap.properties
内容如下:
- # 这个地方,= 前面为 tomcat 的项目名称, 后面为 worker.list 的名称, 如下面就是映射 http://localhost:8080/tomcatprojectname / 这个 tomcat 网站的
- # 如果不加项目名:/*=jdart 会映射所有 tomcat 网站
- /tomcatprojectname/*=jdart
2, 创建如下目录结构
temp 目录, 用于存放 workers.properties 和 uriworkermap.properties
temp\jakarta\目录, 用于放置 isapi_redirect.properties 和 isapi_redirect.dll
目录结构很重要, 如果 isapi_redirect.properties 没有存放到 jakarta 目录, 会出现 GetFilterVersion 失败的 500 错误
3,iis 配置
iis 配置很简单, 主要有下面几点:
1, 对 temp 目录创建一个网站, 然后对 jakarta 目录创建一个虚拟目录, 如果没有 jakarta 目录, 则会映射失败, 出现 404 找不到资源的错误
图 1
2, 在 iis 跟节点的功能列表中增加 isapi 和 CGI 限制, 并设置为允许
ispai 路径, 选择你的 isapi_redirect.dll, 名称随便, 记得要设置为允许
图 2
图 3
图 4 编辑权限
图 5 注意设置为允许
3, 添加 isapi 筛选器
名称最好为 jakarta, 见图 3
4, 在网站的处理程序映射界面, 编辑功能权限, 全选各个权限即可, 见图 4.
到此你如果完整按照上述配置, 应该可以通过 iis 访问到 tomcat 的地址了
整个过程有很多误区:
误区包括:
1, 是否需要修改注册表:
答, 不需要, tomcat docs 里面已经明确说明, The redirector will check for the isapi_redirect.properties file during initialisation, and use it in preference to the registry if present, 所以 isapi_redirect.properties 最优先, 其次才是注册表, 而写注册表非常容易搞错.
需要注意的的是, 这个 properties 文件一定要放在共同目录, 否则无效.
2, 是否需要设置端口:
答, 只有非默认才需要设置, 否则不需要设置
默认就是 ajp13,localhost,8009, 如果有变化你才需要设置, 否则 work.list 后面的的行, 全部可以删除.
3, 是否需要在 tomcat/conf 目录放置那些文件:
答: 不需要, 任意磁盘位置均可
4, 出现 GetFilterVersion 是由于没有写或修改注册表
答: 注册表配置, 基本不会成功, 请用 isapi_redirect.properties 文件, 更为方便
HTTP 错误 500.0 - Internal Server Error》调用 GetFilterVersion 失败, 在 ISAPI 筛选器 "D:\tomcat9\iistomcatconnector\jakarta\isapi_redirect.dll" 上
5, 是否需要配置 tomcat 的 server.xml
答: 根本不需要
6, 是否需要配置 iis 的 jsp 映射
答: 不需要,dll 只按照 uriworkermap.properties 所配置的规则进行目录映射, 比如 springboot 开发的程序, 根本没有扩展名, 更无从配置
来源: https://www.cnblogs.com/johnsen/p/10096222.html