Hello,
Thank you for those who viewed this posting. We have figured the issue with attempting to move the CMS down a directory, off of the web root, using an Apache reverse proxy.
I am submitting my solution here as I know that other people look at the posts here for support.
- What was wrong
The issue with attempting to move the CMS down a directory is that the entrypoint.sh file within the CMS Docker container does handle using the CMS_ALIAS
from the config.env file to modify the .htaccess
file within the /var/www/cms/web/
directory. However, the entrypoint.sh file does not complete all of the actions that would be needed to be done on the .htaccess
file if a person has set the CMS_ALIAS
configuration within the config.env file.
The entrypoint.sh file will uncomment and update the RewriteBase directive in the .htaccess
file with the value of the CMS_ALIAS
set within the config.env file but it does not modify the rewrite conditions for the API end points which it would have to do so if the CMS has moved down a directory.
Here is what the .htaccess
file will look like in the Docker container once the container is spun up and a value is set on the CMS_ALIAS
variable. The below example is with the assumption that the CMS_ALIAS
was set to /cms
.
RewriteEngine On
RewriteBase /cmsRewriteCond %{HTTP:Authorization} .+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/api/authorize/.*$
RewriteRule ^ api/authorize/index.php [QSA,L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/api/.*$
RewriteRule ^ api/index.php [QSA,L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/maint/.*$
RewriteRule ^ maint/index.php [QSA,L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !.(css|js|png|jpg)$
RewriteCond %{REQUEST_URI} !^/dist/.$
RewriteCond %{REQUEST_URI} !^/theme/.$
RewriteRule ^ index.php [QSA,L]
As you can see in the rewrite conditions for the API access points that the rewrite condition is never matched due to the assertion of the start of the line in the regex condition for the API endpoints.
The rewrite conditions will match only when the rewrite base is not used.
- How to fix the issue
What needs to happen is to remove the ^
symbols in the rewrite conditions for the API end points so they look below.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /api/authorize/.*$
RewriteRule ^ api/authorize/index.php [QSA,L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /api/.*$
RewriteRule ^ api/index.php [QSA,L]
The issue is that the .htaccess
file needs to be in the spun up CMS Docker container.
This is how we solved the issue. I have no idea if this would be the correct method or not so if you know a better way to solve this issue please contact me.
- First we obtained a copy of the
.htaccess
file from the spun up Docker container. We pulled a copy of the file when theCMS_ALIAS
in the config.env was active. - We updated the
.htaccess
file to correct for the issue. - We placed the modified
.htaccess
file in our persistent volume for the CMS,/shared/cms/web/
. - We modified the docker-compose.yml file and added a specific file for the
/var/www/cms/web/
directory within the container. What we added was the reference to the modified.htaccess
file. See example below.
cms-web:
image: xibosignage/xibo-cms:release-2.3.10
volumes:
- “./shared/cms/custom:/var/www/cms/custom:Z”
- “./shared/backup:/var/www/backup:Z”
- “./shared/cms/web/theme/custom:/var/www/cms/web/theme/custom:Z”
- “./shared/cms/library:/var/www/cms/library:Z”
- “./shared/cms/web/userscripts:/var/www/cms/web/userscripts:Z”
- “./shared/cms/ca-certs:/var/www/cms/ca-certs:Z”
- “./shared/cms/web/.htaccess:/var/www/cms/web/.htaccess:Z”
- Spin down and up the containers and everything should work after that.
I hope this helps someone someday.