Plone 6, Apacheconfig

We have an internal and some external domains for the accesses to our websites. Normally the internal domain is not rewritten via Apache.
With the internal domain backend and frontend (Development Mode) can start like this:

RAZZLE_DEV_PROXY_API_PATH=http://0.0.0.0:8092  make start-backend &
RAZZLE_DEV_PROXY_API_PATH=http://internal.foo.de:8092/Plone HOST=internal.foo.de make start-frontend

or for Production Mode:

yarn build && RAZZLE_DEV_PROXY_API_PATH=http://internal.foo.de:8092/Plone HOST=internal.foo.de yarn start:prod &

So I can access the frontend via http://internal.foo.de:3000 without any problems.

But when I want to reach the frontend externally, it doesn't work. Maybe it's my apacheconfig, or the start command via yarn, or both. I had oriented myself to this:

RewriteRule ^/\+\+api\+\+($|/.*) http://localhost:8080/VirtualHostBase/http/www.myurl.com:80/Plone/VirtualHostRoot/++api++$1 [P,L]

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

The upper part with the API for the backend had worked. The lower part does not really work. With that also the port 3000 is not really rewritten. I am also not sure with which variables I should execute the start:prod. I have already tried different things with the variables and with the apacheconfig.
As a result I have in any case the problem that the frontend can not reach the backend. Mostly because of CORS errors.

But when I want to reach the frontend externally, it doesn't work

So your Volto setup doesn't work, with Apache, for the external domain?

Yes. The frontend cannot reach the backend when I call the external URL.

Is the Apache running on your own machine?

Because then you say:

So I can access the frontend via http://internal.foo.de:3000 without any problems.

It seems to me that you're complicating the whole thing. If you're just starting with Volto, try to make your setup simpler. Mixing in Apache, running things on different servers, seems complicated, unless you have a good understanding of how to setup the communication between them.

Maybe I didn't describe my setup that well. Everything runs on our web server. There is no mix between servers here.
On the web server are already running several websites with Plone 5 which can be reached without problems via Apache.

Only the new Plone 6 website we can't reach via Apache.

When I start the yarn build and start:prod for the internal URL the frontend is reachable via http://internal.foo.de:3000:

yarn build && RAZZLE_DEV_PROXY_API_PATH=http://internal.foo.de:8092/Plone HOST=internal.foo.de yarn start:prod &

But when I stop that and change the build to start the page from the external URL it doesn't work:

yarn build && RAZZLE_DEV_PROXY_API_PATH=https://external.faa.de/api HOST=external.faa.de yarn start:prod &

Here is the current Apacheconfig:

RewriteEngine On
RewriteRule .well-known - [L]
RewriteRule ^/++api++($|/.) http://127.0.0.1:8092/VirtualHostBase/https/%{SERVER_NAME}:443/Plone/VirtualHostRoot/++api++$1 [L,P]
RewriteRule ^/(.
) http://127.0.0.1:3000/https://%{SERVER_NAME}:443/$1 [L,P]
RewriteRule ^/(.*)/$ http://127.0.0.1:3000/https://%{SERVER_NAME}:443/$1 [L,P]

Peter via Plone Community wrote at 2023-9-29 03:34 +0000:

...
But when I stop that and change the build to start the page from the external URL it doesn't work:

yarn build && RAZZLE_DEV_PROXY_API_PATH=https://external.faa.de/api HOST=external.faa.de yarn start:prod &

At your place, I would setup detailed logging (for Apache)
and then look into the log files to find out where the requests fail.

The Apache log config should be such that Apache logs its rewrite
activity. In (one of) its log file, you can then see how
Apache has rewritten the incoming requests.

In Plone's Z2.log, you can see which requests arrived at the backend
and with what status code they ended (2xx means success, 3xx usually
indicate special (maybe partial) success cases; other codes indicate
errors).

If you see requests with error status, you can look at Plone's
primary log file (--> event.log, near the Z2.log),
or get details via the ZMI from one of the error_log objects
(one in the root, one in your Plone instance).
Plone's error logging is controlled by those error_log objects.
By default, the ignore some kind of errors/exceptions;
a reconfiguration might be necessary to get all errors/exceptions logged.

Note that your "API_PATH" configuration is different for
the working case (it ends in Plone) and the non working case
(it lacks Plone and ends in api).
Your Apache config does not look for /api but for /++api++.
Check which requests arrive at the Apache and whether your rewrite rule
handling the api case fires when it should.

Thanks for the tips. I was able to solve the problem. The main problem was that I had used the wrong variable for the production environment. Correct is RAZZLE_API_PATH and not RAZZLE_DEV_PROXY_API_PATH

yarn build && RAZZLE_API_PATH=https://external.faa.de yarn start:prod &

I have also adjusted the Apacheconfig. Here the config:

       <IfModule mod_rewrite.c>
           RewriteEngine On
           RewriteRule  ^/\+\+api\+\+($|/.*)  http://127.0.0.1:8092/VirtualHostBase/https/%{SERVER_NAME}:443/Plone/VirtualHostRoot/++api++$1 [L,P]
           ProxyPass / http://127.0.0.1:3000/
           ProxyPassReverse / http://127.0.0.1:3000/
      </IfModule>

With Plone 6, does logging actually have to be activated separately? I could not find any log files in my Plone directory.