Espo v7.4.4
cPanel using apache 2.4
modsecurity should be disabled
Scenario: you want a custom portal url (ie. portal.xyz.com) such that a user visits portal.xyz.com and it displays the custom user portal.
Instructions:
1. Create the domain under your cpanel account (ie. portal.xyz.com).
- In my case, espo.xyz.com is the main domain espo is installed on and portal.xyz.com is another domain which will serve a portal
- the DirectoryRoot in cPanel interface for portal.xyz.com would point to {path_to_espo}/public just like it should be for the espo.xyz.com main domain in a production enviornment.
NOTE: The documentation says to point it to {path_to_espo}/public/portal but I have not got that to work. In this example, the portal domain is portal.xyz.com. Replace all references in these instructions with your custom portal domain.
2. Create the portal in espo and give it the custom domain portal.xyz.com. I assume your DNS for portal.xyz.com is pointing correctly to your cPanel server
3. Place the following .conf file at /etc/apache2/conf.d/userdata/ssl/2_4/{cpanelUserName}/portal.xyz.com/espo-portal-production.conf
replace {cpanelUserName} with your cpanel user. The {cpanelUserName} directory should already exist but you may need to create portal.xyz.com directory.
NOTE: you can name the *.conf file whatever you wish. The important part is that you place it under the userdata directory in apache. In my case, I'm using SSL so the conf file will go under that sub directory. If you are not using SSL then replace ssl with std above. apache will autoload any *.conf files under the userdata directories and since we only want this to apply to the portal.xyz.com domain you should create that directory at the path described above.
4. Place the following contents in espo-portal-production.conf.
NOTE: Replace {path-to-espo} with the full path to your espo installation (ie. /home/{cpanelUserName}/public_html/espo.xyz.com/
Replace {custom-portal-id} with the id of your portal shown in the URL when viewing your portal detail view in espo
/etc/apache2/conf.d/userdata/ssl/2_4/{cpanelUserName}/portal.xyz.com/espo-portal-production.conf
Code:
<IfModule mod_fcgid.c> FcgidPassHeader Authorization FcgidPassHeader Proxy-Authorization FcgidPassHeader HTTP_AUTHORIZATION </IfModule> <IfModule mod_fastcgi.c> FastCgiConfig -pass-header Authorization \ -pass-header Proxy-Authorization \ -pass-header HTTP_AUTHORIZATION </IfModule> Alias /client/ /{path-to-espo}/client/ <Directory /{path-to-espo}/> AllowOverride None </Directory> <Directory "/{path-to-espo}/public/"> AllowOverride All RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} !^/portal/ RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^(.*)$ portal/$1 [L] </Directory> <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=ESPO_PORTAL_ID:{custom-portal-id}] </IfModule>
/usr/local/cpanel/scripts/rebuildhttpdconf
/usr/local/cpanel/scripts/restartsrv_httpd
What does this configuration do?
It will re-write the request portal.xyz.com to portal.xyz.com/portal and also pass the portal id along to espo per the docs. The URL will remain portal.xyz.com.
If anyone knows how to actually make it work per the documentation for v7 with the DocumentRoot set to {path_to_espo}/public/portal please advise this board.
Leave a comment: