無法在 Debian 11 上使用 Supervisord 在 Docker 映像之外啟動 Mercure Hub

無法在 Debian 11 上使用 Supervisord 在 Docker 映像之外啟動 Mercure Hub

我正在嘗試從主管處執行 Mercure hub,但對我來說這是不可能的。 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 上停用了 caddy 伺服器,將 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>

透過這種方式,用戶端可以連接到 Mercure 上https://pami54.local/.well-known/mercure,即使發生斷開連接,用戶端也會成功重新連接到集線器,但是當伺服器(webapp)嘗試在集線器上發布通知時,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 元件的錯誤意味著什麼?我以為我已經解決問題了。至少客戶端重新連接到集線器,現在的問題是當 Web 應用程式嘗試發佈到 Mercure 集線器時。

我必須說我的本地環境沒有 dns 伺服器,所有都是在/etc/hostname.confDebian 虛擬機器中聲明的本地虛擬主機和網域:

#/etc/hostname.conf     
debiandev
pami54.local

答案1

我有解決方案。在 Caddyfile 中,我在連接埠 80 上停用了 caddy 伺服器,分配了任何其他連接埠(例如 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
}

現在,用戶端可以連接到集線器,但 Web 應用程式無法在其上發布。

我已經更新了帖子。

相關內容