我正在尝试利用Coldfusion 11的REST服务,但只能使用HTTP协议,无法使用HTTPS。当我将协议更改为HTTPS时,它返回404错误。
我已经采取的步骤:
1)我在Web根目录中创建了一个名为“api-test”的文件夹
2)在该文件夹内,我创建了一个名为“animals.cfc”的文件,其中包含:
<cfcomponent rest="true" restpath="/animals">
<cffunction name="getAnimals" access="remote" httpmethod="GET" produces="application/json" returntype="struct">
<cfset value = { "cats": "dogs", "birds": "snakes" }>
<cfreturn value>
</cffunction>
</cfcomponent>
3) 在 Coldfusion 管理员 中的 Data & Services / REST Services 下,我将 "/web/webapps/api-test" 添加为 根路径,并将 "api-test" 添加为 映射。
4) 在我的 Web 浏览器中,通过 jQuery 和 Firefox 的 Firebug / Web Developer 插件,在同一服务器上登录到其中一个 CF Web 应用程序后 (使用 HTTP),我测试了 API:
$.get("http://cftestapp1.mydomain.com/rest/api-test/animals");
数据返回没有问题。
5)当我将CF Web应用程序的协议更改为HTTPS并使用相同的命令重试时,在我的Web浏览器中会出现404错误。
$.get("https://cftestapp1.mydomain.com/rest/api-test/animals");
我的环境由两个 Web 服务器(cftestapp1 和 cftestapp2)和一个负载均衡器(cftestapps)组成。Web 服务器在 Redhat Linux 上运行 Coldfusion 11,使用 Apache/Tomcat。在测试过程中,我首先尝试了所有负载均衡器的设置,但没有成功,然后我只关注于 "cftestapp1"(如上面的例子)。我查看了所有 Coldfusion 管理员设置和 Apache 的 httpd.conf 文件,但都没有找到问题所在。
我在网上找不到太多相关文档或者有任何人遇到过同样的问题。如果有人有任何见解,请帮忙!谢谢!
编辑:
每次进行 HTTPS 请求时,/etc/httpd/logs/ssl_error_log(在 httpd.conf 中指定)都会显示以下错误:
[Tue Nov 24 16:34:23 2015] [error] [client my_ip_here] File does not exist: /web/webapps/rest
[Tue Nov 24 16:34:23 2015] [error] [client my_ip_here] File does not exist: /web/webapps/opt
我还发现了这个错误,可能与问题无关,因为我们在添加 CF Rest Services 之前从未遇到过 HTTPS 请求的问题。
[Tue Nov 24 16:33:12 2015] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
下面是我们 Apache 配置文件(httpd.conf)的摘录。还有许多其他行,但这些似乎是最相关的。<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/web/webapps">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Include "/etc/httpd/conf/mod_jk.conf"
NameVirtualHost 127.0.0.1:443
<VirtualHost 127.0.0.1:443>
ServerName localhost
DocumentRoot /web/webapps/
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLProtocol +SSLv3 +TLSv1
SSLCipherSuite RSA:!EXP:!NULL:+HIGH:-MEDIUM:-LOW
ErrorLog logs/cfadmin.ssl.error.log
CustomLog logs/cfadmin.ssl.access.log common
</VirtualHost>
ErrorDocument 404 /opt/cf11/cfusion/wwwroot/CFIDE/administrator/templates/404.cfm
看起来HTTPS流量在404和REST服务上没有被正确路由。但是在使用HTTPS时,我能够访问我们/web/webapps网站根目录中的所有其他文件夹,没有任何问题。
https://cftestapp1.mydomain.com/rest/api-test/animals
,它是否有效?我意识到它可能会出现错误或类似的问题,但它是否能够解决?您是否已经将证书导入到服务器上的Java密钥库文件(cacerts)中? - Miguel-Fhttp://cftestapp1.mydomain.com/rest/api-test-break-me/animals
,我会得到一个空白页面。如果我在HTTP中在“/rest/_”之前断开链接https://cftestapp1.mydomain.com/break-me/rest/api-test/animals
,我将得到Coldfusion的404错误。这可能是我们的Apache配置的问题。我已更新我的问题以包含更多有关此事的详细信息。谢谢! - Thomas B