Лак Wordpress SSL Apache - PullRequest
       22

Лак Wordpress SSL Apache

0 голосов
/ 30 ноября 2018

Я использую WordPress, и мне нужен ускоритель веб-страниц.

У меня есть SSL, и я решил установить Varnish.

Конфигурации выглядят так

Запрос -> Apache (: 443) -> Varnish (: 80) -> Apache (: 8080).

Все работает нормально, страница отображается правильно, мой заголовок:

Accept-Ranges    bytes
Age  0
Connection   Keep-Alive
Content-Encoding    gzip
Content-Length  19699
Content-Type    text/html; charset=UTF-8
Date    Thu, 29 Nov 2018 21:11:24 GMT
Keep-Alive  timeout=5, max=100
Link    <https://.../>; rel="https://api.w.org/"
Link    
<https://test.manufakturakawy.com/?p=1>; rel=shortlink
Server  Apache/2.4.18 (Ubuntu)
Vary    Accept-Encoding
Via 1.1 varnish-v4
X-Pingback  https://..../xmlrpc.php
X-Varnish   33072

Проблема в том, что «Age» равен 0.

Я установил [plugin] [1], который говорит:

Cache Service   Varnish caching service is running but is unable to cache your site.

Файл default.vcl почти стандартный:

 vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "127.0.0.1";
    .port = "8080";
}

sub vcl_recv {
    # Happens before we check if we have this in cache already.
    #
    # Typically you clean up the request here, removing cookies you don't need,
    # rewriting the request, etc.


}

sub vcl_backend_response {
    # Happens after we have read the response headers from the backend.
    #
    # Here you clean the response headers, removing silly Set-Cookie headers
    # and other mistakes your backend does.

if (beresp.ttl == 120s) {

    set beresp.ttl = 1h;

  }

}

sub vcl_deliver {
    # Happens when we have all the pieces we need, and are about to send the
    # response to the client.
    #
    # You can do accounting or modifying the final object here.
}



  [1]: https://wordpress.org/plugins/varnish-http-purge/

Не могли бы вы поддержать меня, что я пропустил?

Ответы [ 2 ]

0 голосов
/ 16 июня 2019

Это обновление будет перенаправлять http://example.com на https://example.com

#vi /etc/varnish/default.vcl
sub vcl_recv {
        if (req.http.host ~ "^(www\.)?example\.com$" && req.http.X-Forwarded-Proto !~ "(?i)https") {
                return (synth(750, ""));
        }
}
sub vcl_synth {
    if (resp.status == 750) {
        set resp.status = 301;
        set resp.http.Location = "https://" + req.http.host + req.url;
        return(deliver);
    }
}

sub vcl_hash {
    if (req.http.X-Forwarded-Proto) {
        hash_data(req.http.X-Forwarded-Proto);
    }
}
0 голосов
/ 16 июня 2019

Я устанавливаю это нормально для https://example.com,, но http://example.com не перенаправляет на https://example.com

#/etc/httpd/conf.d/external-https.conf
<VirtualHost *:443>
        ServerName example.com
        ErrorLog              /var/log/httpd/external-https_error.log
        CustomLog             /var/log/httpd/external-https_access.log combined

        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/example.com.crt
        SSLCertificateKeyFile /etc/pki/tls/certs/example.com.key

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

#/etc/httpd/conf.d/internal-http.conf
<VirtualHost 127.0.0.1:8080>
        SetEnvIf X-Forwarded-Proto https HTTPS=on
        ServerName    example.com
        DocumentRoot  /var/www/html/example
        ErrorLog      /var/log/httpd/internal-http_error.log
        CustomLog     /var/log/httpd/internal-http_access.log combined
</VirtualHost>

Apache версии 2.4.6 на CentOS 7

Apache listen port 8080

Varnish версия 5.2

  • Varnish backend listen 8080 (vi /etc/varnish/default.vcl)
  • Varnish params listen80 (vi /etc/varnish/varnish.params)

Подробную форму можно прочитать https://bash -prompt.net / guides / apache-varnish /

...