Не удалось отправить обновление с помощью Mercure в докере с использованием Symfony 7 в рабочей среде. 404 Не найдено, возвращено для MERCURE_URL

Я создаю API, и у меня возникла проблема с отправкой обновлений в Mercure Hub с помощью Symfony 7. Я следую текущей документации Symfony и реализую Mercure с помощью Docker (только Mercure). у меня локально все работает нормально, я отправляю обновление, но на производстве обновление отправить не удалось. Ошибка возвращает мне «Не удалось отправить обновление». и «HTTP/2 404 возвращен для https://example.com/.well-known/mercure». этот маршрут является настройкой MERCURE_URL в переменной env. Я использую Linux-машину ec2 AWS и не использую какой-либо домен или сертификат SSL, я использую только IP-адрес Linux-машины для подключения. Я также использую сервер Apache. Изображения ошибок: Вот мои файлы, как в текущем документе Symfony: compose.override.yaml

version: '3'

services:
###> symfony/mercure-bundle ###
  mercure:
    ports:
      - "80"
###< symfony/mercure-bundle ###

docker-compose.yaml

services:
###> symfony/mercure-bundle ###
  mercure:
    image: dunglas/mercure
    restart: unless-stopped
    environment:
      SERVER_NAME: ':80'
      MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
      MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
      # Set the URL of your Symfony project (without trailing slash!) as value of the cors_origins directive
      MERCURE_EXTRA_DIRECTIVES: |
        cors_origins http://127.0.0.1:8000
    # Comment the following line to disable the development mode
    command: /usr/bin/caddy run --config /etc/caddy/Caddyfile.dev
    volumes:
      - mercure_data:/data
      - mercure_config:/config
###< symfony/mercure-bundle ###

volumes:
###> symfony/mercure-bundle ###
  mercure_data:
  mercure_config:
###< symfony/mercure-bundle ###

.env

###> symfony/mercure-bundle ###
# 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://example.com/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=https://example.com/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET = "!ChangeThisMercureHubJWTSecretKey!"
###< symfony/mercure-bundle ###

конфигурация/пакеты/mercure.yaml

mercure:
    hubs:
        default:
            url: '%env(MERCURE_URL)%'
            public_url: '%env(MERCURE_PUBLIC_URL)%'
            jwt:
                secret: '%env(MERCURE_JWT_SECRET)%'
                publish: '*'

моя конфигурация Apache /etc/apache2/sites-available/taxis-chrono.conf

<VirtualHost *:80>
    ServerName localhost

    # Uncomment the following line to force Apache to pass the Authorization
    # header to PHP: required for "basic_auth" under PHP-FPM and FastCGI
    #
    # SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1

    # <FilesMatch \.php$>
        # when using PHP-FPM as a unix socket
       # SetHandler proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://dummy

        # when PHP-FPM is configured to use TCP
        # SetHandler proxy:fcgi://127.0.0.1:9000
    # </FilesMatch>

    DocumentRoot /var/www/taxis-chrono/public
    <Directory /var/www/taxis-chrono/public>
        AllowOverride None
        Require all granted
        FallbackResource /index.php
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    ErrorLog /var/log/apache2/taxis-chrono_error.log
    CustomLog /var/log/apache2/taxis-chrono_access.log combined
</VirtualHost>

Нужна помощь, пожалуйста.

Я нашел проблему. Похоже, мой докер не взаимодействует с приложением Symfony. Есть ли у кого-нибудь идея поработать с моим Docker Hub и моим приложением Symfony?

Louis Bingana 27.02.2024 15:27
Развертывание модели машинного обучения с помощью Flask - Angular в Kubernetes
Развертывание модели машинного обучения с помощью Flask - Angular в Kubernetes
Kubernetes - это портативная, расширяемая платформа с открытым исходным кодом для управления контейнерными рабочими нагрузками и сервисами, которая...
Как создать PHP Image с нуля
Как создать PHP Image с нуля
Сегодня мы создадим PHP Image from Scratch для того, чтобы легко развернуть базовые PHP-приложения. Пожалуйста, имейте в виду, что это разработка для...
0
1
224
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

После нескольких дней поисков я наконец нашел решение. Дело было в моем докере Mercure. Он запускается, но не взаимодействует с приложением Symfony. Что я делаю, так это настраиваю порт в моем compose.override.yaml следующим образом:


services:
###> symfony/mercure-bundle ###
  mercure:
    ports:
      - "3000:80"
###< symfony/mercure-bundle ### 

и в моем .env я меняю MERCURE_URL и вот так:

# 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=http://127.0.0.1:3000/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=http://127.0.0.1:3000/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET = "!ChangeThisMercureHubJWTSecretKey!"
###< symfony/mercure-bundle ###

и теперь все работает нормально, мое приложение Symfony и мой Mercure в докере эффективно взаимодействуют. Я надеюсь, что этот ответ поможет кому-то еще.

Другие вопросы по теме