Назад | Перейти на главную страницу

Прямая проверка подлинности пользователя прокси не работает

У меня есть простой прокси-сервер, для которого требуется аутентификация пользователя и белый список IP-адресов. Я создал vhost ниже:

ProxyRequests On
ProxyVia On

<Proxy xx.xxx.xx.xxx:8888>
   Order deny,allow
   Allow from xx.xxx.xx.xxx
   Allow from xx.xxx.xx.xxx
   Allow from xx.xxx.xx.xxx
   Allow from xx.xxx.xx.xxx

   AuthType Basic
   AuthName "Password Required for Proxy"
   AuthUserFile /etc/apache2/.proxyhtpasswd
   Require user
</Proxy>

Сам прокси работает нормально, но аутентификация пользователя и разрешение IP-адресов - нет. Я менял конфигурацию 10 раз, и даже с одним только блоком Auth он по-прежнему работает без использования (действительного) пользователя / пароля или наличия правильного IP-адреса.

Я также попытался настроить это через обычную конфигурацию VirtualHost, но безуспешно:

<VirtualHost xx.xxx.xx.xxx:8888>
    ProxyRequests On
    ProxyVia On
    SSLProxyEngine On

    <Location />
        Order Deny,Allow
        Deny from all
        Allow from xx.xxx.xx.xxx
        Allow from xx.xxx.xx.xxx
        Allow from xx.xxx.xx.xxx
        Allow from xx.xxx.xx.xxx

        AuthType Basic
        AuthBasicProvider file
        AuthName "Password Required for Proxy"
        AuthUserFile /etc/apache2/.proxyhtpasswd
        Require valid-user
    </Location>
</VirtualHost>

Я исправил проблему, объединив директиву Proxy с директивой VirtualHost.

<VirtualHost xx.xxx.xx.xxx:8888>
    ProxyRequests On
    ProxyVia On
    SSLProxyEngine On

    <Proxy *>
        Order Deny,Allow
        Deny from all
        Allow from xx.xxx.xx.xxx
        Allow from xx.xxx.xx.xxx
        Allow from xx.xxx.xx.xxx
        Allow from xx.xxx.xx.xxx

        AuthType Basic
        AuthBasicProvider file
        AuthName "Password Required for Proxy"
        AuthUserFile /etc/apache2/.proxyhtpasswd
        Require valid-user
    </Proxy>

    LogLevel warn
    ErrorLog ${APACHE_LOG_DIR}/proxy-error.log
    CustomLog ${APACHE_LOG_DIR}/proxy-access.log combined
</VirtualHost>

Я думаю это либо

Require valid-user

или

Require user [theusername]

но нет

Require user

Видеть: http://httpd.apache.org/docs/current/mod/core.html#require