安装框架(问题 cURL 错误 6:无法解析主机:缓存代理)

Installing the Framework (Problem cURL error 6: Could not resolve host: cache-proxy)

我尝试安装 api-平台:https://api-platform.com/docs/distribution/

启动后我在日志中看到"api-platform-242_cache-proxy_1"

│   Error:                                                                                                                                                                                                                                                    │
│   Message from VCC-compiler:                                                                                                                                                                                                                                │
│   Expected return action name.                                                                                                                                                                                                                              │
│   ('/usr/local/etc/varnish/default.vcl' Line 67 Pos 13)                                                                                                                                                                                                     │
│       return (miss);                                                                                                                                                                                                                                        │
│   ------------####--                                                                                                                                                                                                                                        │
│   Running VCC-compiler failed, exited with 2                                                                                                                                                                                                                │
│   VCL compilation failed  

如果我使用api(post问候),响应码是500 "hydra:description": "cURL error 6: Could not resolve host: cache-proxy (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)", "trace":[

尽管如此,实体仍然被插入。

此外,我尝试了没有 docker (Apache) 的 api 平台。 我删除了 .env 文件中的 VARNISH_URL=http://cache-proxy 行。 然后 return 代码是 500 "cURL error 3: malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"

你有什么想法吗?

亲切的问候 路堤

从 api_platform.yaml

移除清漆

我认为您应该从 .env 文件而不是 api_platform.yaml 中删除或注释掉 VARNISH_URL=http://cache-proxy,因为您的 .env 可以更改并且 is/should 取决于主机和配置 (.yaml) 不应该。

参见:https://symfony.com/doc/current/configuration.html#the-env-file-environment-variables

There is also a .env file which is loaded and its contents become environment variables. This is useful during development, or if setting environment variables is difficult for your deployment.

api_platform.yaml 中,您应该注释掉整个 http_cache 部分,否则您将不断收到有关 guzzle 格式错误的 cURL 错误。

{ "@context": "/api-platform/api/public/contexts/Error", "@type": "hydra:Error", "hydra:title": "An error occurred", "hydra:description": "cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)", "trace": [ { "namespace": "", "short_class": "", "class": "", "type": "", "function": "", "file": "...\api-platform\api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php", "line": 186, "args": [] },

效果是一样的

我遇到了同样的问题,我已经解决了!

如此处所述:https://github.com/api-platform/api-platform/issues/777,问题是 directories/files 权限,因此我没有下载 zip 或 tar.gz 存档,而是克隆了 repo,

我执行的所有命令(在为 Windows 安装 Docker 并在 Docker 中为 Windows 设置启用共享驱动器之后):

cd my_parent_directory
git clone https://github.com/api-platform/api-platform.git
cd api-platform
docker-compose pull
docker-compose up -d

当我继续 https://localhost:8443 一切正常!!

希望对您有所帮助:)