I have Apache server with few sites.
I would like to run on this server docker container with Mercure and share it on the Internet.
I found information on the Internet that I need to use ProxyPass and ProxyPassReverse in the vhost configuration.
My vhost configuration:
<VirtualHost *:80>
ServerName tomaszf.pl
ServerAlias www.tomaszf.pl
DocumentRoot /var/www/html/mercurytest/public
DirectoryIndex /index.php
<Directory /var/www/html/mercurytest/public>
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /index.php
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php8.0-fpm.sock|fcgi://localhost"
</FilesMatch>
<Directory /var/www/html/mercurytest/public/bundles>
DirectoryIndex disabled
FallbackResource disabled
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tomaszf.pl.error.log
CustomLog ${APACHE_LOG_DIR}/tomaszf.pl.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.tomaszf.pl [OR]
RewriteCond %{SERVER_NAME} =tomaszf.pl
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName tomaszf.pl
ServerAlias www.tomaszf.pl
DocumentRoot /var/www/html/mercurytest/public
DirectoryIndex /index.php
<Directory /var/www/html/mercurytest/public>
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /index.php
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php8.0-fpm.sock|fcgi://localhost"
</FilesMatch>
<Directory /var/www/html/mercurytest/public/bundles>
DirectoryIndex disabled
FallbackResource disabled
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tomaszf.pl.error.log
CustomLog ${APACHE_LOG_DIR}/tomaszf.pl.log combined
SSLCertificateFile /etc/letsencrypt/live/tomaszf.pl/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/tomaszf.pl/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
ProxyPass /mercure http://127.0.0.1:8099/
ProxyPassReverse /mercure http://127.0.0.1:8099/
</VirtualHost>
Docker container is launched with the command:
docker run \
-e SERVER_NAME=':80' \
-e MERCURE_PUBLISHER_JWT_KEY='!ChangeMe!' \
-e MERCURE_SUBSCRIBER_JWT_KEY='!ChangeMe!' \
-p 8099:80 \
-e CORS_ALLOWED_ORIGINS='https://tomaszf.pl' \
-e DEBUG=1 \
-e ALLOW_ANONYMOUS=1 \
dunglas/mercure caddy run -config /etc/caddy/Caddyfile.dev
Problem:
When you try to enter the website tomaszf.pl/mercure, the address in the browser is automatically changed to 127.0.0.1 and website not working.
What do I have to change in the configuration?