重定向

场景说明

  • 假设我们的web server已经升级为https,希望将所有的http请求重定向至https
    • 域名:example.org

样例配置上添加一些新的配置,就可以实现上述重定向行为

  • 首先,bfe启用mod_redirect模块(bfe.conf第51行)
  1. Modules = mod_redirect #启用mod_redirect
  • 配置redirect模块

    1. [basic]
    2. DataPath = mod_redirect/redirect.data
    1. {
    2. "Version": "init version",
    3. "Config": {
    4. "example_product": [{
    5. "Cond": "!req_proto_secure() && req_host_in(\"example.org\")",
    6. "Actions": [{
    7. "Cmd": "SCHEME_SET",
    8. "Params": [
    9. "https"
    10. ]
    11. }],
    12. "Status": 301
    13. }]
    14. }
    15. }
  • 现在,用curl验证下是否配置成功

curl -H “host: example.org” “http://127.1:8080/test“ 将返回301,Location指向https://example.org/test