使用 Symfony 和 Apache 在生产环境中运行 Mercure | HTTPS问题

问题描述

我有一个 symfony 应用程序,我正在使用 Mercure。

要运行 Mercure,我使用此命令

SERVER_NAME=:3000 MERCURE_PUBLISHER_JWT_KEY='something' MERCURE_SUBSCRIBER_JWT_KEY='something' CORS_ALLOWED_ORIGINS=https://my-domain.cz ALLOW_ANONYMOUS=1 ./mercure run -config Caddyfile

我已经安装了 Let's encrypt 授权的 SSL 证书。 我的阿帕奇:

<VirtualHost *:80>
....
ProxyRequests off
<LocationMatch /mercure>
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000

...
RewriteCond %{SERVER_NAME} =my-domain.cz
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

问题。当我尝试订阅某个主题时收到此错误

GET https://my-domain.cz:3000/.well-kNown/mercure?topic=someGoodTopic net::ERR_SSL_PROTOCOL_ERROR

如果我尝试从浏览器获取这个 URL,我会遇到同样的问题,但是如果我尝试使用 http:// 一切都会好的,但不幸的是我无法从我的 https 域请求 http .

(Mixed Content: The page at 'https://my-domain.cz/' was loaded over HTTPS,but requested an insecure EventSource endpoint 'http://my-domain.cz:3000/.well-kNown/mercure?topic=someGoodTopic'. This request has been blocked; the content must be served over HTTPS.)

如果有人能帮助我,我会很高兴 =)

解决方法

不确定这是否是答案,但您的错误可能与允许匿名连接到 mercure 相关。除此之外,它看起来不错。不久前我通过 https 设置了 mercure,实际上并没有什么具体的事情需要做。尝试使用 mercure 设置身份验证,然后告诉我进展如何。