Docker 이미지 외부의 Supervisord를 사용하여 Debian 11에서 Mercure Hub를 시작할 수 없습니다.

Docker 이미지 외부의 Supervisord를 사용하여 Debian 11에서 Mercure Hub를 시작할 수 없습니다.

감독자로부터 Mercure 허브를 실행하려고 하는데 불가능합니다. Mercure는 도메인용 SSL 가상 호스트가 있는 동일한 웹 서버 시스템에 있습니다 pami54.local.

[program:mercure]
environment=JWT_KEY="m3rcu353cr37pa55pra53DEV"; CORS_ALLOWED_ORIGINS="https://pami54.local"; PUBLISH_ALLOWED_ORIGINS="*"; ADDR="pami54.local:3000"
command=/home/frizquierdo/mercureLinux/mercure run -config /home/frizquierdo/mercureLinux/Caddyfile
process_name=%(program_name)s_$(process_num)s
numprocs=1
autostart=true
#directory=/tmp
autorestart=true
startsecs=5
startretries=10
redirect_stderr=false
stdout_capture_maxbytes=1MB
stderr_capture_maxbytes=1MB
stdout_logfile=/var/log/supervisor/mercureout.log
stderr_logfile=/var/log/supervisor/mercureerror.log

편집하다:

부분적인 솔루션을 찾았습니다. Caddyfile에서 포트 80의 캐디 서버를 비활성화하고 auto_https 지시문을 'disable_redirects'로 설정하고 Caddyfile을 다음과 같이 유지했습니다.

# Learn how to configure the Mercure.rocks Hub on https://mercure.rocks/docs/hub/config
{
   {$GLOBAL_OPTIONS}
   auto_https disable_redirects
}

pami54.local:3000

log

tls /etc/apache2/ssl-cert/pami54.local.crt /etc/apache2/ssl-cert/pami54.local.key

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
        cors_origins https://pami54.local
        publish_origins *
        {$MERCURE_EXTRA_DIRECTIVES}
    }

    respond /healthz 200

    respond "Not Found" 404
}

가상호스트 구성:

<IfModule mod_ssl.c>
 #SSLStaplingCache "shmcb:${SRVROOT}/logs/ssl_stapling(32768)"
 <VirtualHost *:443>
   ServerName pami54.local
   ServerAlias wwww.pami54.local

   DocumentRoot "/var/www/html/pami54.local/public"
   DirectoryIndex index.php

   <Directory "/var/www/html/pami54.local/public/">
    AllowOverride All
    Order Allow,Deny
    Allow from All
    #Require local
    Require all granted

    <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
   </Directory>

   SSLEngine on
   SSLProtocol all -SSLv3 -SSLv2
   SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
   SSLCertificateFile "/etc/apache2/ssl-cert/pami54.local.crt"
   SSLCertificateKeyFile "/etc/apache2/ssl-cert/pami54.local.key"
   SSLUseStapling off

   <FilesMatch "\.(cgi|shtml|pl|asp|php)$">
    SSLOptions +StdEnvVars
   </FilesMatch>

   BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0

   SSLProxyEngine On
   ProxyRequests Off
   ProxyPreserveHost On
   #ProxyPass '/.well-known/mercure' 'https://pami54.local:3000/.well-known/mercure' connectiontimeout=300 timeout=300
   ProxyPass '/.well-known/mercure' 'https://pami54.local:3000/.well-known/mercure'
   ProxyPassReverse '/.well-known/mercure' 'https://pami54.local:3000/.well-known/mercure'
 </VirtualHost>
</IfModule>

이 방법으로 클라이언트는 https://pami54.local/.well-known/mercure연결이 끊긴 경우에도 Mercure에 연결할 수 있습니다. 클라이언트는 허브에 성공적으로 다시 연결되지만 서버(웹 앱)가 허브에 알림을 게시하려고 하면 Symfony http 클라이언트 로그 오류가 발생합니다.

[2022-04-27T19:29:40.857698-04:00] http_client.INFO: Request: "POST https://pami54.local/.well-known/mercure" [] []
[2022-04-27T19:29:40.871491-04:00] messenger.WARNING: Error thrown while handling message App\Message\NotificacionMarcarComoLeidaMessage. Sending for retry #1 using 1000 ms delay. Error: "Handling "App\Message\NotificacionMarcarComoLeidaMessage" failed: Failed to send an update." {"message":{"App\\Message\\NotificacionMarcarComoLeidaMessage":[]},"class":"App\\Message\\NotificacionMarcarComoLeidaMessage","retryCount":1,"delay":1000,"error":"Handling \"App\\Message\\NotificacionMarcarComoLeidaMessage\" failed: Failed to send an update.","exception":"[object] (Symfony\\Component\\Messenger\\Exception\\HandlerFailedException(code: 0): Handling \"App\\Message\\NotificacionMarcarComoLeidaMessage\" failed: Failed to send an update. at /var/www/html/pami54.local/vendor/symfony/messenger/Middleware/HandleMessageMiddleware.php:129)\n[previous exception] [object] (Symfony\\Component\\Mercure\\Exception\\RuntimeException(code: 0): Failed to send an update. at /var/www/html/pami54.local/vendor/symfony/mercure/src/Hub.php:104)\n[previous exception] [object] (Symfony\\Component\\HttpClient\\Exception\\TransportException(code: 0): The request was not processed and can be safely retried at /var/www/html/pami54.local/vendor/symfony/http-client/Response/CommonResponseTrait.php:148)\n[previous exception] [object] (Symfony\\Component\\HttpClient\\Exception\\TransportException(code: 0): The request was not processed and can be safely retried at /var/www/html/pami54.local/vendor/symfony/http-client/Chunk/ErrorChunk.php:65)\n[previous exception] [object] (Amp\\Http\\Client\\Connection\\UnprocessedRequestException(code: 0): The request was not processed and can be safely retried at /var/www/html/pami54.local/vendor/amphp/http-client/src/Connection/DefaultConnectionFactory.php:117)\n[previous exception] [object] (Amp\\Http\\Client\\SocketException(code: 0): Connection to 'pami54.local:443' failed at /var/www/html/pami54.local/vendor/amphp/http-client/src/Connection/DefaultConnectionFactory.php:118)\n[previous exception] [object] (Amp\\Socket\\ConnectException(code: 111): Connection to tcp://pami54.local:443 refused at /var/www/html/pami54.local/vendor/amphp/socket/src/DnsConnector.php:108)"} []

이 오류는 Symfony HTTP CLIENT 구성 요소가 발생한다는 것을 의미합니까? 나는 문제를 해결했다고 생각했습니다. 적어도 클라이언트는 허브에 다시 연결합니다. 이제 웹 애플리케이션이 Mercure 허브에 게시하려고 할 때 문제가 발생합니다.

내 로컬 환경에는 DNS 서버가 없으며 모두 /etc/hostname.conf데비안 가상 머신에 선언된 로컬 가상 호스트와 도메인 이름이 있습니다.

#/etc/hostname.conf     
debiandev
pami54.local

답변1

해결책이 있습니다. Caddyfile에서 포트 80의 캐디 서버를 비활성화하여 다른 포트(예: 8081)를 할당하고 auto_https지시문을 'disable_redirects'로 설정하여 Caddyfile다음과 같이 유지했습니다.

# Learn how to configure the Mercure.rocks Hub on https://mercure.rocks/docs/hub/config
{
   {$GLOBAL_OPTIONS}
   http_port 8081
   auto_https disable_redirects
}

pami54.local:3000

log

tls /etc/apache2/ssl-cert/pami54.local.crt /etc/apache2/ssl-cert/pami54.local.key

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
        cors_origins https://pami54.local
        publish_origins *
        {$MERCURE_EXTRA_DIRECTIVES}
    }

    respond /healthz 200

    respond "Not Found" 404
}

이제 클라이언트가 허브에 연결할 수 있지만 웹 애플리케이션은 허브에 게시할 수 없습니다.

게시물을 업데이트했습니다.

관련 정보