AI编程生活评测

Apache使用ProxyPass做请求代理转发

编程笔记 / 2022-03-16 / 1 min
在开发环境 Apache 上使用 ProxyPass 做代理转发:

环境:

平台:windows Apache版本:2.4.52 (x64)

报错信息:

[Tue Mar 15 16:02:19.205633 2022] [proxy:warn] [pid 34720:tid 2032] [client 127.0.0.1:49686] AH01144: No protocol handler was valid for the URL /api/cms/autoSchedule/antiSpam/import (scheme 'http'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
从错误信息来看是代理模块 proxy 相关的问题,确认一下配置:

httpd-vhosts.conf 配置:

/api 的请求转发到 /http处理。
<VirtualHost *:80>
    DocumentRoot "d:/projects/test/public"
    ServerName test.local
    <Directory "d:/projects/test">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ProxyPass /api http://test.local/http
</VirtualHost>

httpd.conf 配置:

httpd.conf 中开启以下模块:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_http2_module modules/mod_proxy_http2.so
根据环境的不一样开启相应的代理模块。 重启 Apache 问题解决。
点击刷新