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

Использование Apache в качестве обратного прокси https для лака

В дебиан джесси Я пытаюсь обслуживать https с помощью обратного прокси-сервера Varnish и нашел следующее решение: http://davidbu.ch/mann/blog/2015-03-20/varnish-and-https-apache.html : apache управляет ssl-данными на порту 443, затем переходит к varnish на порту 80, который переходит к apache на порт 8080.

Однако запрашивая https://myserver.com/index.html Получаю в браузере:

403 Forbidden

You don't have permission to access / on this server.

В журнале ошибок Apache говорится:

[authz_core:error] [pid 12662] [client 151.16.175.15:38240] AH01630: client denied by server configuration: proxy:http://127.0.0.1:80/index.html

Что мне не хватает?

Мое определение vhost

<VirtualHost *:8080>
    ServerAdmin mymail@gmail.com
    ServerName myserver.com

    DocumentRoot /home/paolo/weewx
    <Directory /home/paolo/weewx/>
        DirectoryIndex index.html
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    # ErrorDocument 404 /index.html

    CustomLog /var/log/apache2/access.log combined

</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin mymail@gmail.com
    ServerName myserver.com

    DocumentRoot /home/paolo/weewx/
    <Directory /home/paolo/weewx/>
        DirectoryIndex index.html
        Options FollowSymLinks
        AllowOverride All
        order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    # ErrorDocument 404 /index.html

    CustomLog /var/log/apache2/access.log combined

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:80/
    ProxyPassReverse / http://127.0.0.1:80/
    RequestHeader set X-Forwarded-Port "443"
    RequestHeader set X-Forwarded-Proto "https"

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/qumran2/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/qumran2/privkey.pem
</VirtualHost>


</IfModule>

Я бы не стал устанавливать корень документа в записи виртуального хоста, который будет использоваться только для прокси-запросов. Особенно когда вы включаете AllowOverride All директива tehre и .htaccess файлы могут вступить в игру.

Для отладки также может помочь определение отдельных файлов журнала для каждой записи виртуального хоста.

<VirtualHost *:443>
    ServerAdmin mymail@gmail.com
    ServerName example.com
    LogLevel warn
    ErrorLog /var/log/apache2/example.com-ssl-error.log
    CustomLog /var/log/apache2/example.com-ssl-access.log combined
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:80/
    ProxyPassReverse / http://127.0.0.1:80/
    RequestHeader set X-Forwarded-Port "443"
    RequestHeader set X-Forwarded-Proto "https"
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/qumran2/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/qumran2/privkey.pem
</VirtualHost>

И вы можете отлаживать, запрашивая ресурс напрямую с порта 8080, например, curl --verbose --header 'Host: example.com' 'http://localhost:8080/index.html' чтобы убедиться, что проблема в этом VirtualHost.

Если это не так; затем попробуйте лак на порту 80, чтобы узнать, не в лаке ли проблема. curl --verbose --header 'Host: example.com' 'http://localhost:80/index.html