【问题标题】:Configuration of Mercure with Symfony 5使用 Symfony 5 配置 Mercure
【发布时间】:2021-12-27 03:58:29
【问题描述】:

我正在尝试编写与 Symfony 5 和 Mercure 聊天的代码,但我在配置方面遇到了一些问题。我使用的是 Windows 10。

这是我遵循的文档:https://github.com/dunglas/mercure/blob/main/docs/hub/install.md

我在我的项目中安装了这个版本:mercure_0.13.0_Windows_arm64.zip。 然后,我解压它,然后在我的终端中运行“composer require symfony/mercure”。

这是在我的.env:

# See https://symfony.com/doc/current/mercure.html#configuration
# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
MERCURE_URL=:https://127.0.0.1:8000/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=https://127.0.0.1:8000/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET="!ChangeMe!"
###< symfony/mercure-bundle ###```

Then I ran the Mercure server with this command line : ```$env:MERCURE_PUBLISHER_JWT_KEY='!ChangeMe!'; $env:MERCURE_SUBSCRIBER_JWT_KEY='!ChangeMe!'; .\mercure.exe run -config Caddyfile.dev```.

In my PowerShell, I have this : 
```2021/11/16 01:39:58.029 INFO    http    server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2021/11/16 01:39:58.029 INFO    http    enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2021/11/16 01:39:58.111 INFO    tls     cleaning storage unit   {"description": "FileStorage:C:\\Users\\toufi\\AppData\\Roaming\\Caddy"}
2021/11/16 01:39:58.113 INFO    tls     finished cleaning storage units
2021/11/16 01:39:58.134 INFO    pki.ca.local    root certificate is already trusted by system   {"path": "storage:pki/authorities/local/root.crt"}
2021/11/16 01:39:58.135 INFO    http    enabling automatic TLS certificate management   {"domains": ["localhost"]}
2021/11/16 01:39:58.136 WARN    tls     stapling OCSP   {"error": "no OCSP stapling for [localhost]: no OCSP server specified in certificate"}
2021/11/16 01:39:58.143 INFO    autosaved config (load with --resume flag)      {"file": "C:\\Users\\toufi\\AppData\\Roaming\\Caddy\\autosave.json"}
2021/11/16 01:39:58.143 INFO    serving initial configuration```

It seems to run well, but in my browser when I run ```https://localhost/.well-known/mercure```,
I have :
```Not Found
The requested URL was not found on this server.

Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/7.4.25 Server at localhost Port 443```

Someone can help me because I don't know how to access to my Mercure server with my browser ?

Thank you very much

【问题讨论】:

    标签: php symfony ssl mercure


    【解决方案1】:

    嘿,你应该尝试在你的浏览器中运行https://localhost:8000/.well-known/mercure 而不是https://localhost/.well-known/mercure

    【讨论】:

    • 我在浏览器中尝试了https://localhost:8000/.well-known/mercure,但收到了这条消息:Ce site ne peut pas fournir de connexion sécurisée localhost a envoyé une réponse incorrecte. Essayez d'exécuter les diagnostics réseau de Windows. ERR_SSL_PROTOCOL_ERROR
    • 你必须在你的 Caddyfile.dev 文件中配置 ssl 或者如果你不想使用 https 则禁用它
    • 对不起,我发现配置 ssl 的唯一文档是 Docker,但我没有使用它
    • 要完全禁用 HTTPS,请在您的 caddyfile.dev 中将 auto_https 全局选项设置为关闭以获取更多信息,您可以查看mercure.rocks/docs/hub/config
    • 我在我的文件中这样做了:{ {$GLOBAL_OPTIONS} } { auto_https off } {$SERVER_NAME:localhost} log route { encode zstd gzip mercure { # Transport to use (default to Bolt) transport_url {$MERCURE_TRANSPORT_URL:bolt://mercure.db} # Publisher JWT key publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG} # Subscriber JWT key subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG} # Extra directives {$MERCURE_EXTRA_DIRECTIVES} } respond /healthz 200 respond "Not Found" 404 }
    猜你喜欢
    • 2021-05-09
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 2021-07-16
    • 1970-01-01
    • 1970-01-01
    • 2021-07-04
    相关资源
    最近更新 更多