Varni sh выдает 503 ошибки - PullRequest
       55

Varni sh выдает 503 ошибки

0 голосов
/ 19 февраля 2020

Мне удалось настроить Redis, nginx и varni sh для magento 2 в Ubuntu без SSL.

Выполнены все необходимые шаги, необходимые для настройки varni sh с помощью nginx.

Ниже приведены файлы конфигурации.

  1. / etc / default / varni sh

varnish

/ lib / systemd / system / varni sh .service

varnish.service

/ etc / varnish / default.vcl

default.vcl

/ etc / nginx / sites-available / magento

sites-available/magento

Журнал ошибок: varnishlog -q 'RespStatus == 503' - g request

-   Begin          req 32779 rxreq
-   Timestamp      Start: 1582114572.814013 0.000000 0.000000
-   Timestamp      Req: 1582114572.814013 0.000000 0.000000
-   ReqStart       122.170.13.29 49606
-   ReqMethod      GET
-   ReqURL         /
-   ReqProtocol    HTTP/1.1
-   ReqHeader      Host: 13.126.114.136
-   ReqHeader      User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0
-   ReqHeader      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
-   ReqHeader      Accept-Language: en-US,en;q=0.5
-   ReqHeader      Accept-Encoding: gzip, deflate
-   ReqHeader      Connection: keep-alive
-   ReqHeader      Cookie: PHPSESSID=8hie1n4ddjurjoup67keoblubv; form_key=pKBGXC2YzDcWL6pi; mage-cache-storage=%7B%7D; mage-cache-storage-section-invalidation=%7B%7D; mage-cache-sessid=true; mage-messages=; recently_viewed_product=%7B%7D; recently_viewed_product_previous=%
-   ReqHeader      Upgrade-Insecure-Requests: 1
-   ReqHeader      Cache-Control: max-age=0
-   ReqHeader      X-Forwarded-For: 122.170.13.29
-   VCL_call       RECV
-   ReqHeader      grace: none
-   ReqURL         /
-   ReqUnset       Accept-Encoding: gzip, deflate
-   ReqHeader      Accept-Encoding: gzip
-   VCL_return     hash
-   VCL_call       HASH
-   VCL_return     lookup
-   VCL_call       MISS
-   VCL_return     fetch
-   Link           bereq 32781 fetch
-   Timestamp      Fetch: 1582114572.814245 0.000232 0.000232
-   RespProtocol   HTTP/1.1
-   RespStatus     503
-   RespReason     Backend fetch failed
-   RespHeader     Date: Wed, 19 Feb 2020 12:16:12 GMT
-   RespHeader     Server: Varnish
-   RespHeader     Content-Type: text/html; charset=utf-8
-   RespHeader     Retry-After: 5
-   RespHeader     X-Varnish: 32780
-   RespHeader     Age: 0
-   RespHeader     Via: 1.1 varnish (Varnish/5.2)
-   VCL_call       DELIVER
-   RespUnset      Age: 0
-   RespHeader     Pragma: no-cache
-   RespHeader     Expires: -1
-   RespHeader     Cache-Control: no-store, no-cache, must-revalidate, max-age=0
-   RespUnset      Server: Varnish
-   RespUnset      X-Varnish: 32780
-   RespUnset      Via: 1.1 varnish (Varnish/5.2)
-   VCL_return     deliver
-   Timestamp      Process: 1582114572.814265 0.000252 0.000019
-   RespHeader     Content-Length: 282
-   RespHeader     Connection: keep-alive
-   Timestamp      Resp: 1582114572.814298 0.000285 0.000033
-   ReqAcct        1095 0 1095 269 282 551
-   End            
**  << BeReq    >> 32781     
--  Begin          bereq 32780 fetch
--  Timestamp      Start: 1582114572.814101 0.000000 0.000000
--  BereqMethod    GET
--  BereqURL       /
--  BereqProtocol  HTTP/1.1
--  BereqHeader    Host: 13.126.114.136
--  BereqHeader    User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0
--  BereqHeader    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
--  BereqHeader    Accept-Language: en-US,en;q=0.5
--  BereqHeader    Cookie: PHPSESSID=8hie1n4ddjurjoup67keoblubv; form_key=pKBGXC2YzDcWL6pi; mage-cache-storage=%7B%7D; mage-cache-storage-section-invalidation=%7B%7D; mage-cache-sessid=true; mage-messages=; recently_viewed_product=%7B%7D; recently_viewed_product_previous=%
--  BereqHeader    Upgrade-Insecure-Requests: 1
--  BereqHeader    X-Forwarded-For: 122.170.13.29
--  BereqHeader    grace: none
--  BereqHeader    Accept-Encoding: gzip
--  BereqHeader    X-Varnish: 32781
--  VCL_call       BACKEND_FETCH
--  VCL_return     fetch
--  FetchError     no backend connection
--  Timestamp      Beresp: 1582114572.814144 0.000042 0.000042
--  Timestamp      Error: 1582114572.814148 0.000046 0.000004
--  BerespProtocol HTTP/1.1
--  BerespStatus   503
--  BerespReason   Service Unavailable
--  BerespReason   Backend fetch failed
--  BerespHeader   Date: Wed, 19 Feb 2020 12:16:12 GMT
--  BerespHeader   Server: Varnish
--  VCL_call       BACKEND_ERROR
--  BerespHeader   Content-Type: text/html; charset=utf-8
--  BerespHeader   Retry-After: 5
--  VCL_return     deliver
--  Storage        malloc Transient
--  ObjProtocol    HTTP/1.1
--  ObjStatus      503
--  ObjReason      Backend fetch failed
--  ObjHeader      Date: Wed, 19 Feb 2020 12:16:12 GMT
--  ObjHeader      Server: Varnish
--  ObjHeader      Content-Type: text/html; charset=utf-8
--  ObjHeader      Retry-After: 5
--  Length         282
--  BereqAcct      0 0 0 0 0 0
--  End            

Пробовал несколько решений, найденных здесь, но ни одно из них не работает.

1 Ответ

1 голос
/ 19 февраля 2020

varnishlog сообщает вам no backend connection, что, скорее всего, будет означать неудачную проверку работоспособности.

Для подтверждения выполните varnishlog -g raw -i Backend_Health

Примечание: лучше установить pub каталог Magento, чтобы быть веб root (директива root в NGINX) по соображениям безопасности. Впоследствии отредактируйте файл VCL на , удалите pub из проверки работоспособности, поскольку все пути, доступные через Интернет, будут относиться к сети root.

Это также может быть неверной конфигурацией. стека. В ваших конфигах NGINX слушает по интерфейсу обратной связи 127.0.0.1. Но в Varni sh вы устанавливаете бэкэнд на localhost. В некоторых ситуациях это может разрешить петлевой интерфейс IPv6 ::1, и Varni sh может не установить соединение с NGINX, поскольку он не прослушивает ::1. Так что это помогает быть согласованным и поместить 127.0.0.1 в файл VCL, чтобы убедиться, что он обращается к правильному интерфейсу, где NGINX прослушивает.

После того, как это будет исправлено, подтвердите интерфейс прослушивания NGINX доступно, например, путем попытки telnet in:

telnet 127.0.0.1 8080

Если вы не получаете сообщения об отказе в соединении, интерфейс NGINX listen доступен. В противном случае необходимо внести дополнительные исправления.

...