为了应对AJAX调用的同源策略,我想允许mod_rewrite和mod_proxy以类似的方式处理这些调用,如另一个答案中所述 :
rewriteEngine on rewriteRule proxy/(.+)$ http://api.example.com/$1 [P]
不过,我正在通过networking阅读所有使用mod_proxy可能是危险的业务。
所以我的问题是:是否有任何安全问题启用mod_proxy并以上述方式使用它? 如果是这样,我应该select什么样的configuration来安全地使用mod_proxy网关?
谢谢,任何帮助表示赞赏。
PS:是的,我知道CORS是解决同源问题的一个更合理的方法,但是我正在使用的远程站点有点不愿意支持CORS,所以我必须寻找替代scheme。
请务必ProxyRequests Off以防止滥用您的服务器作为开放代理; 从文档 :
ProxyRequests Directive Description: Enables forward (standard) proxy requests Syntax: ProxyRequests On|Off Default: ProxyRequests Off Context: server config, virtual host This allows or prevents Apache from functioning as a forward proxy server. (Setting ProxyRequests to Off does not disable use of the ProxyPass directive.) In a typical reverse proxy or gateway configuration, this option should be set to Off.
关于安全问题:您会看到日志中的所有请求,因此请确保它们受到保护,并且不会包含可能用于获取未经授权的访问的“令人感兴趣”的信息,如令牌或其他内容。