Mercure with Apache

Spread the love

One of the things which I absolutely love about ApiPlatform is its deep integration with Mercure and all the real time stuff which just works.

My issue this week was, the server was Apache… and I could not just copy/paste from the docs.

Here is what worked as our final setup:

JWT_KEY='!ChangeMe!' CORS_ALLOWED_ORIGINS=* ADDR='localhost:3000' /home/mercure/mercure

and for apache the following conf:

<VirtualHost *:443>
    ServerName my_dmain_in_dns
    ServerAlias my_dmain_in_dns
    ProxyRequests Off
 ### your SSL key info here
 <LocationMatch /hub >
       ProxyPass http://localhost:3000
       ProxyPassReverse http://localhost:3000

Keep in mind, now your client will connect to my_domain_in_dns/hub and it will be routed to localhost:3000

Then of course setup supervisor and good to go!