Announcement

Collapse
No announcement yet.

501 Not Implemented Error on Custom Portal URL v7

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 501 Not Implemented Error on Custom Portal URL v7

    Description
    When following the instructions listed at https://docs.espocrm.com/administrat...configuration/ for v7 for a custom portal, the calls to any script involving /api/v1/portal-access/ result in a 501 Not implemented error. I am using Apache 2.4 on a CPanel server

    To Reproduce
    Steps to reproduce the behavior:
    1. Fresh install of Espo 7.4.3
    2. Create a custom portal with custom url
    3. In apache .conf file, configure in accordance with documentation specified above:
    DocumentRoot /{path_to_espo}/public/portal/
    Alias /client/ /{path_to_espo}/client/
    Alias /api/v1/ /{path_to_espo}/public/api/v1/

    <Directory /{path_to_espo}/public/>
    AllowOverride All
    </Directory>

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=ESPO_PORTAL_ID:{PORTAL_ID}]
    </IfModule>


    ...

    Expected behavior
    I expect the portal login page to load currently and it does not. The scripts calling /api/v1/portal-access/ result in a 501 Not Implemented error
    Screenshots
    If applicable, add screenshots to help explain your problem.

    EspoCRM version
    Specify the EspoCRM version (or versions) on which the bug occurs.
    7.4.3, 7.4.4
    Additional context
    It is unclear as to why the /client/ Alias works as expected as all the requests for those files seem to load fine. It is specific to the XHR requests for
    https://{custom-domain-name}/api/v1/portal-access/{portal-id}/Settings
    https://{custom-domain-name}/api/v1/portal-access/{portal-id}/I18n?default=true

    These both result in 501 Not Implemented errors with nothing in the Espo Log to debug the issue.

  • #2
    i have face same issue when was using cpanel couldn't figure out a way even the hosting provider couldn't help, if i remember one way was to create a subdomain with redirect. i decided to not use cpanel anymore it adds more constraints so went with a vps using LEMP stack and all worked well.

    i think emillod or Eblasoft could help, contact them through their websites.

    Good luck

    Comment


    • #3
      Hello Guys,
      rabii thank you for mentioning me.

      We have some experience with cPanel on VPS with proper access, but we haven't updated this to 7.4 yet. We'll have to check it out. You can contact us through email available on our website

      Comment


      • #4
        I have created the subdomain that the portal is assigned to. I don't see why a re-direct is necessary as the Document root for the subdomain I created is pointing to /{path_to_espo}/public/portal/​

        The domain loads its just not processing /api/v1/ correctly with the configuration settings in the subdomain's .conf file stated above. I have got it to work by pointing the sub-domain for the portal to DocumentRoot /{path_to_espo}/public/ instead of /{path_to_espo}/public/portal/

        If I do that, and use everything else stated in the configuration above I can access the portal login screen using https://sub.xyz/portal/. The RewriteRule stated above correctly passes the portalD.

        I would go to production with this approach but there are two issues:

        1). I want my subdomain to be portal.xyz so having people go to portal.xzy/portal is not desired
        2). visiting portal.xyz will show the main espo login URL

        I believe that is why the DocumentRoot must be set to /{path_to_espo}/public/portal but when you do this, the XHR calls to https://{custom-domain-name}/api/v1/portal-access/ return 501 Not implemented

        I guess I'll reach out to dev.crm.it

        Comment


        • #5
          api/v1/portal-access/ has rewrite rules (mod_rewrite) in .htaccess (to handle API paths). Your apache does not support it for some reason.

          Did you check apache log?
          Last edited by yuri; 05-12-2023, 06:03 PM.

          Comment


          • czcpf
            czcpf commented
            Editing a comment
            The contents of .htaccess in api/v1/portal-access/ is:

            DirectoryIndex index.php

            Options -Indexes

            RewriteEngine On

            # Some hosts may require you to use the `RewriteBase` directive.
            # If you need to use the `RewriteBase` directive, it should be the
            # absolute physical path to the directory that contains this htaccess file.
            #
            # RewriteBase /

            RewriteRule .* - [E=HTTP_ESPO_CGI_AUTH:%{HTTP:Authorization}]

            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [QSA,L]

            RewriteRule /?web\.config - [F]

            What is interesting is this is slightly different than what is shown in GitHub master, namely:
            DirectoryIndex index.php
            Options -Indexes

            I wonder if those get added on the install?

          • yuri
            yuri commented
            Editing a comment
            Our installer does not modify .htaccess. Maybe you did it before or the hosting provider automatically.

          • czcpf
            czcpf commented
            Editing a comment
            Regardless, commenting out the two lines made no difference to this issue. I guess I'm stuck re-directing to /portal as stated below.

            # DirectoryIndex index.php
            # Options -Indexes

        • #6
          The only way I have gotten the custom domain portal to work is by setting the Document Root to /{path_to_espo}/public/ and adding the following to the custom domain's http .conf file:

          Alias /client/ {path_to_espo}/client/

          <Directory /{path_to_espo}/>
          AllowOverride None
          </Directory>

          <Directory /{path_to_espo}/public/>
          AllowOverride All
          </Directory>

          <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteRule ^/$ /portal [R]
          RewriteRule .* - [E=ESPO_PORTAL_ID:{portal_id}]
          </IfModule>​


          Thus, when visiting the custom portal domain https://xyz.com the redirect rule above redirects the request to https://xyz.com/portal and everything works. I don't want have to do this but I cannot get it to work otherwise.

          Comment


          • #7
            UPDATE 1 Here is a solution which works

            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>​
            5. Restart apache and rebuild main cpanel apache configuration file

            /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.

            Last edited by czcpf; 05-13-2023, 12:24 AM.

            Comment

            Working...
            X