volto icon indicating copy to clipboard operation
volto copied to clipboard

Handle no root publishing

Open cekk opened this issue 4 years ago • 4 comments

with these changes, it is possible to publish a volto site not in the domain root

cekk avatar Nov 02 '21 08:11 cekk

i made some tests with different env vars configurations and ended up with a almost working thing with:

RAZZLE_API_PATH = http://my-domain.com/name
RAZZLE_PUBLIC_URL = http://my-domain.com/name

This is a snippet from Varnish where i do rewrites for backend/frontend:

    set req.backend_hint = volto;
    
    if (req.url ~ "/name/..api..") {
        set req.backend_hint = plone;

        if (req.url ~ "/..api../name") {
            set req.url = regsub(req.url, "/..api../name", "/++api++");
        }
        if (req.url ~ "/name/..api..") {
            set req.url = regsub(req.url, "/name/..api..", "/++api++");
        }
        set req.url = "/VirtualHostBase/http/" + req.http.host + "/Plone/VirtualHostRoot/_vh_name" + req.url;
        return(pass);
    }

There are some things to fix, for example Volto still publish static folder on the domain root and not under /name. I don't know where this is set and if it's possible to fix it @sneridagh

cekk avatar Nov 02 '21 08:11 cekk

@tiberiuichim i have a problem with static resources: they're always served on the root (http://localhost:3001/static/whatever.js) but i need to tell volto to serve them with an additional prefix (http://localhost:3001/foo/static/whatever.js).

my guess was that problem could be here and can be fixed setting the custom name for static resources like this:

.use('/foo',express.static(process.env.RAZZLE_PUBLIC_DIR))

like explained in express documentation but it seems not working.

Any ideas? Maybe there is something else that is configured for static resources somewhere?

cekk avatar Nov 05 '21 16:11 cekk

I was able to get a Volto master running on a subpath with the following docker-compose.yml:

env RAZZLE_API_PATH=http://water.ro/api yarn start:prod
version: '2'
services:
  apache-https:
    image: eeacms/apache:2.4-2.2
    ports:
      - "80:80"
    environment:
      APACHE_CONFIG: |-
        <VirtualHost *:80>
            ServerName water.ro

            ErrorLog /var/log/apache.log

            RewriteEngine On
            SSLProxyEngine on

            ProxyTimeout 1200
            Timeout 1200

            RewriteRule ^/freshwater/static/(.*) http://192.168.100.5:3000/freshwater/static/$$1 [P,L]
            RewriteRule ^/static(.*) http://192.168.100.5:3000/freshwater/static/$$1 [P,L]

            RewriteRule ^/api/\+\+api\+\+\/freshwater(.*) http://192.168.100.5:8080/VirtualHostBase/http/water.ro:80/Plone/VirtualHostRoot/_vh_freshwater$$1 [P,L]

            RewriteRule ^/api(.*) http://192.168.100.5:8080/VirtualHostBase/http/water.ro:80/Plone/VirtualHostRoot/_vh_freshwater$$1 [P,L]

            RewriteRule ^/freshwater(.*) http://192.168.100.5:3000/$$1 [P,L]

        </VirtualHost>
      TZ: Europe/Copenhagen

Problems with this setup:

  • the login redirects to a broken URL
  • the vocabularies are loaded wrong, like http://water.ro/api/++api++/@vocabularies/http://water.ro/freshwater/@vocabularies/plone.app.vocabularies.SupportedContentLanguages?b_start=0

tiberiuichim avatar Nov 12 '21 09:11 tiberiuichim

Related to https://github.com/plone/volto/issues/4290 , to determine which one is the canonical and if we can close this one.

sneridagh avatar Mar 31 '24 15:03 sneridagh