如何修复 Magento-1.9.4 中的“无法将 VCL 应用到 127.0.0.1:6082:无法从 Varnish 读取响应代码”错误

Posted

技术标签:

【中文标题】如何修复 Magento-1.9.4 中的“无法将 VCL 应用到 127.0.0.1:6082:无法从 Varnish 读取响应代码”错误【英文标题】:How to fix 'Failed to apply the VCL to 127.0.0.1:6082: Failed to read response code from Varnish' error in Magento-1.9.4 【发布时间】:2019-09-06 16:55:17 【问题描述】:

我正在尝试将 Varnish-4.1 安装到 magento-1.9,该 varnish 单独工作正常但是当我尝试在 Admin->system->Cache management 中单击 btn 时,它会在标题中显示错误: 将 VCL 应用到 127.0.0.1:6082 失败:无法从 Varnish 读取响应代码

操作系统:Ubuntu 18.04 阿帕奇:2.4.29(Ubuntu)端口:8080 php 7.1.28-1+ubuntu18.04.1 Magento 版本。 1.9.4.1 varnish-4.1.11 端口 80 来自:https://packagecloud.io/varnishcache/varnish41/install#manual-deb

/etc/systemd/system/varnish.service 的内容

[Unit]
Description=Varnish HTTP accelerator
Documentation=https://www.varnish-cache.org/docs/4.1/ man:varnishd

[Service]
Type=simple
LimitNOFILE=131072
LimitMEMLOCK=82000
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m -p vcc_allow_inline_c=on -p feature=+esi_ignore_other_elements -p feature=+esi_disable_xml_check
ExecReload=/usr/share/varnish/reload-vcl
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
PrivateDevices=true

[Install]
WantedBy=multi-user.target

sudo systemctl status varnish

● varnish.service - Varnish HTTP accelerator
   Loaded: loaded (/etc/systemd/system/varnish.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/varnish.service.d
           └─override.conf
   Active: active (running) since Tue 2019-04-16 16:13:42 CEST; 24min ago
     Docs: https://www.varnish-cache.org/docs/4.1/
           man:varnishd
 Main PID: 31280 (varnishd)
    Tasks: 218 (limit: 4915)
   CGroup: /system.slice/varnish.service
           ├─31280 /usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m -p vcc_allow_inline_c=on -p feature=+esi_ignore_other_elements -p feature=+esi_disable_xml_check
           └─31385 /usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m -p vcc_allow_inline_c=on -p feature=+esi_ignore_other_elements -p feature=+esi_disable_xml_check

Apr 16 16:26:07 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37242 127.0.0.1 6082 Rd "ban" "obj.http.X-Varnish-Session" "==" "i0fmpqecahms4mi8olvi3uamk5" "&&" "obj.http.X-Turpentine-Flush-Events" "~" "core_session_abstract_add_message"
Apr 16 16:26:07 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37242 127.0.0.1 6082 Wr 200
Apr 16 16:26:16 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37246 127.0.0.1 6082 Rd "auth" "long key"
Apr 16 16:26:16 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37246 127.0.0.1 6082 Wr 200 -----------------------------
                                                Varnish Cache CLI 1.0
                                                -----------------------------
                                                Linux,4.18.0-17-generic,x86_64,-junix,-smalloc,-smalloc,-hcritbit
                                                varnish-4.1.11 revision 61367ed17d08a9ef80a2d42dc84caef79cdeee7a

                                                Type 'help' for command list.
                                                Type 'quit' to close CLI session.
Apr 16 16:26:16 ubunut varnishd[31280]: CLI telnet 127.0.0.1 37246 127.0.0.1 6082 Rd "param.show" "feature"
Apr 16 16:26:16 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37246 127.0.0.1 6082 Wr 200 feature
                                                        Value is: +esi_disable_xml_check,+esi_ignore_other_elements
                                                        Default is: none

                                                        Enable/Disable various minor features.
                                                           none                       Disable all features.

                                                        Use +/- prefix to enable/disable individual feature:
                                                           short_panic                Short panic message.
                                                           wait_silo                  Wait for persistent silo.
                                                           no_coredump                No coredumps.
                                                           esi_ignore_https           Treat HTTPS as HTTP in
                                                                                      ESI:includes
                                                           esi_disable_xml_check      Don't check of body looks like
                                                                                      XML
                                                           esi_ignore_other_elements  Ignore non-esi XML-elements
                                                           esi_remove_bom             Remove UTF-8 BOM
                                                           https_scheme               Also split https URIs
Apr 16 16:26:16 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37248 127.0.0.1 6082 Rd "auth" "long key"
Apr 16 16:26:16 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37248 127.0.0.1 6082 Wr 200 -----------------------------
                                                Varnish Cache CLI 1.0
                                                -----------------------------
                                                Linux,4.18.0-17-generic,x86_64,-junix,-smalloc,-smalloc,-hcritbit
                                                varnish-4.1.11 revision 61367ed17d08a9ef80a2d42dc84caef79cdeee7a

                                                Type 'help' for command list.
                                                Type 'quit' to close CLI session.
Apr 16 16:26:16 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37248 127.0.0.1 6082 Rd "ban" "obj.http.X-Varnish-Session" "==" "i0fmpqecahms4mi8olvi3uamk5" "&&" "obj.http.X-Turpentine-Flush-Events" "~" "core_session_abstract_add_message"
Apr 16 16:26:16 ubuntu varnishd[31280]: CLI telnet 127.0.0.1 37248 127.0.0.1 6082 Wr 200

我想要的最终结果只是让它说应用成功或类似的东西。 注意:我知道密钥与 \n 正确放置。这也是我尝试安装清漆的链接: https://www.howtoforge.com/tutorial/how-to-setup-magento-2-with-varnish-and-apache-on-ubuntu-1604/ 我跳过了有关 lamp 和 magento 的所有内容,因为它已经安装并正在运行,我只运行了 varnish 部分的命令。 提前致谢

【问题讨论】:

【参考方案1】:

如果你想检查 Varnish 是否在 Magento 前正确运行,你可以运行 curl -I localhost 你应该得到一个标题,其中提到 Varnish 并从你的后端提供内容。

【讨论】:

这导致curl: (52) Empty reply from server 没关系,现在修复了错误的端口设置,我可以从 curl 中看到标题,感谢您指出,但主要问题仍然在这里failed to read responce code

以上是关于如何修复 Magento-1.9.4 中的“无法将 VCL 应用到 127.0.0.1:6082:无法从 Varnish 读取响应代码”错误的主要内容,如果未能解决你的问题,请参考以下文章

如何修复错误无法将 [NSDictionary] 快速转换为 NSDictionary?

如何在此 for 循环中修复'无法将'String'类型的值转换为预期的参数类型'Int'

如何修复:无法将“CLLocationDegrees”(又名“Double”)类型的值分配给“Float!”在斯威夫特 3

如何使用在设计时获取“无法将 NIL 分配给 TFont”的 TFont 属性修复 Delphi 组件?

基于OpenCV修复表格缺失的轮廓--如何识别和修复表格识别中的虚线

如何修复错误:无法将类型“java.lang.String”的值转换为所需类型“java.lang.Long”;