Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubleshooting Mercure deployment on Digital Ocean APP Platform #842

Open
jeandanyel opened this issue Dec 5, 2023 · 0 comments
Open

Comments

@jeandanyel
Copy link

Hello,

I'm using Mercure on a project deployed on Digital Ocean APP Platform and I'm struggling to make it work properly.

Despite having no errors, when I inspect the request, it appears to be stuck at "pending," and the EventStream tab is missing.

Both Caddy and Mercure are at their latest versions and everything works perfectly in my local development environment.

Caddyfile

{
	{$DEBUG}

	{$CADDY_GLOBAL_OPTIONS}

	# https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
	order mercure after encode
	order vulcain after reverse_proxy
}

{$CADDY_EXTRA_CONFIG}

{$SERVER_NAME:localhost} {
	log {
		# Redact the authorization query parameter that can be set by Mercure
		format filter {
			wrap console
			fields {
				uri query {
					replace authorization REDACTED
				}
			}
		}
	}

	root * /srv/app/public
	encode zstd gzip

	mercure {
		# Transport to use (default to Bolt)
		transport_url {$MERCURE_TRANSPORT_URL:local://local}

		# 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}
		
	cors_origins *
		publish_origins *
		anonymous

		# Extra directives
		{$MERCURE_EXTRA_DIRECTIVES}
	}

	vulcain

	push

	php_fastcgi unix//var/run/php/php-fpm.sock {
		# Allow x-forwarded-* headers to pass through
		# https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#defaults
		trusted_proxies private_ranges
	}

	file_server
}

docker-compose.yml

version: "3.4"

services:
  php:
    build:
      context: .
      target: symfony_php
      args:
        SYMFONY_VERSION: ${SYMFONY_VERSION:-}
        SKELETON: ${SKELETON:-symfony/website-skeleton}
        STABILITY: ${STABILITY:-stable}
        GITHUB_ACCESS_TOKEN: ${GITHUB_ACCESS_TOKEN}
    restart: unless-stopped
    volumes:
      - php_socket:/var/run/php
      - caddy_data:/data
      - caddy_config:/config
    healthcheck:
      interval: 10s
      timeout: 3s
      retries: 3
      start_period: 30s
    environment:
      # Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
      # For PHP:
      MERCURE_URL: ${MERCURE_URL:-http://caddy/.well-known/mercure}
      MERCURE_PUBLIC_URL: https://${ROUTER_CONTEXT_HOST:-localhost}/.well-known/mercure
      MERCURE_JWT_SECRET: ${MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
      # For Caddy:
      SERVER_NAME: ${SERVER_NAME:-localhost}, caddy:80 
      MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
      MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
      TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}
      TRUSTED_HOSTS: ^${SERVER_NAME:-example\.com|localhost}|caddy$$
    ports:
      # HTTP
      - target: 80
        published: ${HTTP_PORT:-80}
        protocol: tcp
      # HTTPS
      - target: 443
        published: ${HTTPS_PORT:-443}
        protocol: tcp
      # HTTP/3
      - target: 443
        published: ${HTTP3_PORT:-443}
        protocol: udp

# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###


volumes:
  php_socket:
  caddy_data:
  caddy_config:
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###

Environnement variables

SERVER_NAME=my.domain.com:80
ROUTER_CONTEXT_HOST=my.domain.com
MERCURE_URL=http://localhost/.well-known/mercure
MERCURE_PUBLIC_URL=https://my.domain.com/.well-known/mercure
MERCURE_JWT_SECRET=...
MERCURE_PUBLISHER_JWT_KEY=...
MERCURE_SUBSCRIBER_JWT_KEY=...
image image

I hope I have provided enough information for you to guide me.

Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant