仅针对特定目录的基本验证

发布于 2025-01-25 06:33:06 字数 1819 浏览 5 评论 0原文

我有一个小的环境,在一台服务器上有3个服务,我想将所有三个服务都放在反向代理后面。

  1. 在端口9090上运行的Prometheus Server
  2. 在端口9093上运行的Grafana
  3. 在端口3000上运行的Grafana

我的当前配置在下面

<VirtualHost *:80>
    ServerName metrics.example.com
    Redirect permanent / https://metrics.example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName metrics.example.com

    SSLEngine on
    SSLProtocol all -SSLv2 -SSLv3

    SSLCertificateFile /etc/apache2/ssl.crt/example.crt
    SSLCertificateKeyFile /etc/apache2/ssl.key/example.key

    ErrorLog /var/log/apache2/metrics.example.com-error_log
    CustomLog /var/log/apache2/metrics.example.com-access_log combined

    <Location "/">
        ProxyPreserveHost On
        ProxyPass http://localhost:9090/
        ProxyPassReverse http://localhost:9090/
    </Location>

    <Location "/alertmanager/">
        ProxyPreserveHost On
        ProxyPass http://localhost:9093/
        ProxyPassReverse http://localhost:9093/
    </Location>

    <Location "/grafana/">
        RequestHeader set X-Forwarded-Proto "https"
        ProxyPreserveHost On
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </Location>

    # <Proxy *>
    #     AuthType Basic
    #     AuthName "Restricted Content"
    #     AuthUserFile /etc/apache2/.htpasswd
    #     Require valid-user
    # </Proxy>
</VirtualHost>

,现在一切正常,但是Prometheus和AlertManager没有自己的auth,Grafana却没有。如果我的摘要部分,格拉法纳停止工作。目的是通过基本AUTH保护Prometheus和Alertmanager,而不是Grafana实例。 是否有可能(以及如何)保护根(“ /”)目录和 /AlertManager子目录,但在单个vhost中省略 /grafana子目录?

I have a small envirnment where I have 3 services on one server and I want to put all three behind a reverse proxy.

  1. Prometheus server running on port 9090
  2. Prometheus Alert manager running on port 9093
  3. Grafana running on port 3000

My current configuration is below

<VirtualHost *:80>
    ServerName metrics.example.com
    Redirect permanent / https://metrics.example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName metrics.example.com

    SSLEngine on
    SSLProtocol all -SSLv2 -SSLv3

    SSLCertificateFile /etc/apache2/ssl.crt/example.crt
    SSLCertificateKeyFile /etc/apache2/ssl.key/example.key

    ErrorLog /var/log/apache2/metrics.example.com-error_log
    CustomLog /var/log/apache2/metrics.example.com-access_log combined

    <Location "/">
        ProxyPreserveHost On
        ProxyPass http://localhost:9090/
        ProxyPassReverse http://localhost:9090/
    </Location>

    <Location "/alertmanager/">
        ProxyPreserveHost On
        ProxyPass http://localhost:9093/
        ProxyPassReverse http://localhost:9093/
    </Location>

    <Location "/grafana/">
        RequestHeader set X-Forwarded-Proto "https"
        ProxyPreserveHost On
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </Location>

    # <Proxy *>
    #     AuthType Basic
    #     AuthName "Restricted Content"
    #     AuthUserFile /etc/apache2/.htpasswd
    #     Require valid-user
    # </Proxy>
</VirtualHost>

For now everything works, but Prometheus and Alertmanager don't have own auth, Grafana does. If I uncomment section Grafana stops working. The goal is to protect both Prometheus and Alertmanager with basic auth but not the Grafana instance.
Is it possible (and how) to protect root ("/") directory and /alertmanager subdirectory but with omitting /grafana subdirectory in single vhost?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文