Announcement

Collapse
No announcement yet.

access to a portal by custom URL with NGINX

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

  • access to a portal by custom URL with NGINX

    Hello,

    for customizing an access to a portal by custom URL I've found the documentation for Apache at https://github.com/espocrm/documenta...tion/portal.md. But how to configure nginx for an access to a portal by custom URL?

    Can anyone help me?

  • #2
    Has nobody an idea?

    Comment


    • #3
      Hello,

      I've tried a lot of time to get a working access by a custom portal-url to our portal based on nginx. But I've no success...
      For example I want to get access to the portal
      http://my-domain.tld/portal/5c3a08c31353eb361/
      by
      http://my-portal.my-domain.tld
      So I've created this subdomain and it points to the same IP as the main domain. On the nginx server I've created a new server-block that also points to the same directory (/data/www/ESPOCRM) as well as the server-block of my-domain.tld.
      All EspoCRM functionalities of my-domain.tld or working fine as well as the access to the portal by http://my-domain.tld/portal/5c3a08c31353eb361/ . But I got no access to the portal by using the custom url http://my-portal.my-domain.tld .
      This is my nginx conf file for the custom url:

      --------------------------------------------------------
      ### CONF file for my-portal.my-domain.tld
      ### root points to /data/www/ESPOCRM (like root of main domain my-domain.tld)

      server {
      listen 80;
      listen [::]:80;
      server_name my-portal.my-domain.tld;

      root "/data/www/ESPOCRM";
      index index.html index.htm index.cgi index.php ;

      location ~* \.(php|phtml)$ {
      fastcgi_pass unix:/run/php-fpm.sock;
      fastcgi_param HOST "my-portal.my-domain.tld";
      include fastcgi.conf;
      }

      client_max_body_size 0;

      fastcgi_param HTTP_ESPO_CGI_AUTH $http_authorization;

      ### special directives for my-portal.my-domain.tld
      ### equal to documentation sample of
      ### https://www.espocrm.com/documentatio...ration/portal/
      ### for Apache:
      ### RewriteCond %{HTTP_HOST} ^portal-host-name.com$
      ### RewriteRule ^client - [L]
      ###
      ### RewriteCond %{HTTP_HOST} ^portal-host-name.com$
      ### RewriteCond %{REQUEST_URI} !^/portal/{PORTAL_ID}/.*$
      ### RewriteRule ^(.*)$ /portal/{PORTAL_ID}/$1 [L]
      ###

      rewrite ^/client/(.*) /client/$1 break;
      if ($uri !~ "^/portal/5c3a08c31353eb361/.*$"){
      rewrite ^/(.*)$ /portal/5c3a08c31353eb361/$1 break;
      }
      ### end of special directives

      location / {
      allow all;
      try_files $uri $uri/ /index.php?$query_string;
      }
      location /api/v1/ {
      if (!-e $request_filename){
      rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;
      }
      }
      location /portal/ {
      try_files $uri $uri/ /portal/index.php?$query_string;
      }
      location /api/v1/portal-access {
      if (!-e $request_filename){
      rewrite ^/api/v1/(.*)$ /api/v1/portal-access/index.php last; break;
      }
      }
      location ~ /reset/?$ {
      try_files /reset.html =404;
      }
      location ^~ (data|api)/ {
      if (-e $request_filename){
      return 403;
      }
      }
      location ^~ /data/logs/ {
      deny all;
      }
      location ^~ /data/config.php {
      deny all;
      }
      location ^~ /data/cache/ {
      deny all;
      }
      location ^~ /data/upload/ {
      deny all;
      }
      location ^~ /data/\.backup/ {
      deny all;
      }
      location ^~ /application/ {
      deny all;
      }
      location ^~ /custom/ {
      deny all;
      }
      location ^~ /vendor/ {
      deny all;
      }
      location ~ /\.ht {
      deny all;
      }
      }
      --------------------------------------------------------


      And thats a snippet of the log file with "rewrite_log on"directly after calling my-portal.my-domain.tld :
      --------------------------------------------------------
      1: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/client/(.*)" does not match "/", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      2: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/portal/5c3a08c31353eb361/.*$" does not match "/", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      3: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/(.*)$" matches "/", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      4: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 rewritten data: "/portal/5c3a08c31353eb361/", args: "", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      5: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/client/(.*)" does not match "/portal/index.php", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      6: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/portal/5c3a08c31353eb361/.*$" does not match "/portal/index.php", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      7: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/(.*)$" matches "/portal/index.php", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      8: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 rewritten data: "/portal/5c3a08c31353eb361/portal/index.php", args: "", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      9: 2019/01/13 21:55:33 [error] 15190#15190: *78773 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "my-portal.my-domain.tld"
      10: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/client/(.*)" does not match "/favicon.ico", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      11: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/portal/5c3a08c31353eb361/.*$" does not match "/favicon.ico", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      12: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/(.*)$" matches "/favicon.ico", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      13: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 rewritten data: "/portal/5c3a08c31353eb361/favicon.ico", args: "", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      14: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/client/(.*)" does not match "/portal/index.php", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      15: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/portal/5c3a08c31353eb361/.*$" does not match "/portal/index.php", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      16: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 "^/(.*)$" matches "/portal/index.php", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      17: 2019/01/13 21:55:33 [notice] 15190#15190: *78773 rewritten data: "/portal/5c3a08c31353eb361/portal/index.php", args: "", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      18: 2019/01/13 21:55:33 [error] 15190#15190: *78773 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "my-portal.my-domain.tld"
      --------------------------------------------------------

      You can see the errors in line 9 and 18. They are caused by rewriting /portal/index.php with /portal/5c3a08c31353eb361/portal/index.php.But if I changed the rewriting with /portal/5c3a08c31353eb361/index.php by inserting the statementin the conf file
      rewrite ^/portal/(.*)$ /portal/5c3a08c31353eb361/$1 break;
      directly before
      rewrite ^/(.*)$ /portal/5c3a08c31353eb361/$1 break;
      I got an error, too (see lines 10 and 20):
      --------------------------------------------------------
      ...
      9: 2019/01/13 22:15:47 [notice] 18906#18906: *78784 rewritten data: "/portal/5c3a08c31353eb361/index.php", args: "", server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", host: "my-portal.my-domain.tld"
      10: 2019/01/13 22:15:47 [error] 18906#18906: *78784 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, server: my-portal.my-domain.tld, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "my-portal.my-domain.tld"
      ...
      19: 2019/01/13 22:15:47 [notice] 18906#18906: *78784 rewritten data: "/portal/5c3a08c31353eb361/index.php", args: "", server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", host: "my-portal.my-domain.tld"
      20: 2019/01/13 22:15:47 [error] 18906#18906: *78784 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, server: my-portal.my-domain.tld, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "my-portal.my-domain.tld"
      --------------------------------------------------------


      I am desperate. Can anyone help me?

      Comment


      • #4
        Hello.
        Please read this and check if you didn't miss something https://www.digitalocean.com/communi...n-ubuntu-16-04. If nothing isn't missed, and it is still doesn't work, try to input next URL: http://my-portal.my-domain.tld/portal. When I configured my apache2 for portal access according to recommended in Espo documentation parameters it helped me to get access to my portal.

        Comment


        • #5
          Hello, Did you find a solution i have the same problem.
          Thank you

          Comment


          • #6
            I have posted the solution here : https://forum.espocrm.com/forum/deve...with-subdomain

            Comment

            Working...
            X