V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Oct31Dec25
V2EX  ›  问与答

Authelia 网站鉴权(Caddy 请求头问题)

  •  
  •   Oct31Dec25 · 39 天前 · 959 次点击
    这是一个创建于 39 天前的主题,其中的信息可能已经有所发展或是发生改变。

    下面配置可以正常运行:

    用 caddy 代理到了公网:

    auth.xx.com {
            reverse_proxy localhost:9091
    }
    

    auth.xx.com 正常访问登陆。


    需要认证的网站:

    app.xx.com {
            forward_auth http://localhost:9091  {
                uri /api/verify?rd=https://auth.xx.com
            }
            reverse_proxy localhost:3002
    }
    

    也可以正常访问登陆。


    问题是:

    http://localhost:9091
    

    换成了

    https://auth.xx.com
    

    后,打开app.xx.com直接跳过了鉴权,进入到里边了。

    authelia 日志什么都没输出,应该是访问没到达 authelia ,猜测是请求头问题, 瞎改了几个请求头,发现可以跳转到认证登陆页面,但提示:"!检索当前用户状态时出现问题"(不能正常登陆)

    我一直搞不懂请求头,所以想问问大佬的看法。

    Oct31Dec25
        1
    Oct31Dec25  
    OP
       39 天前 via Android
    网页访问: https://auth.xx.com/api/verify
    显示 200 OK
    Oct31Dec25
        2
    Oct31Dec25  
    OP
       24 天前
    已解决:

    认证端代理
    ```
    auth.xx.com {
    reverse_proxy localhost:9091 {
    trusted_proxies 1.1.1.1/32 2.2.2.2/32
    header_up Host {upstream_hostport}
    }
    }
    ```

    APP 端代理
    ```
    app.xx.com {
    forward_auth https://auth.xx.com {
    uri /api/authz/forward-auth?
    header_up Host {upstream_hostport}
    }
    reverse_proxy localhost:3002
    }
    ```
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3045 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 11:59 · PVG 19:59 · LAX 04:59 · JFK 07:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.