Nginx and Docker issue

Hi,

I am trying to deploy a plone 6 in docker on a server that already has nginx pointer to other sites but on the links on the new site I get ":null" inserted into the urls like this "https://pd-new.example.com/:null/about-us" and lower down in the site I get these "http://:null/about-us/case-studies"

I used the nginx-volto-plone docker-compose file and removed nginx part. In the frontend I set

   environment:
      RAZZLE_INTERNAL_API_PATH: http://backend:8080/mysite
      RAZZLE_API_PATH: https://pd-new.example.com
    ports:
      - "3010:3000"

In my server nginx I added a config with

upstream frontend {
  server: localhost:3010
}

server {
        server_name pd-new.example.com;

        location ~* \.(ico|jpg|jpeg|png|gif|svg|js|jsx|css|less|swf|eot|ttf|otf|woff|woff2)$ {
                add_header Cache-Control "public";
                expires +1m;
                proxy_pass http://frontend;
        }
        location ~ / {
                proxy_pass http://fontend;
        }
}

Any ideas where I'm going wrong?
TIA

1 Like

I read this post with interest and tried out some of the suggestions made there but I still have ":null" appearing in my links. One thing I did not mention above is that if I have over a link and refresh the page, the path initially seems correct (ie. no null included "https://pd-new.example.com/about-us") but then I see in the console

https://pd-new.example.com/resolveuid/undefined

And after that the path changes to include the ":null" for example "https://pd-new.example.com/:null/about-us". So somehow the resolveuid call is not being sent to the backend.

as a first idea i would try make the ports consistent.I also removed RAZZLE variables except RAZZLE_DEV_PROXY_API_PATH to run volto seamless.

environment:
      #RAZZLE_INTERNAL_API_PATH: http://backend:8080/mysite
      #RAZZLE_API_PATH: https://pd-new.example.com
      RAZZLE_DEV_PROXY_API_PATH: http://backend:8080/mysite
      PORT=3010
    ports:
      - "3010:3010"

You may also check the output of

bash> docker logs frontend
Volto is running in SEAMLESS mode
Proxying API requests from http://localhost:3010/++api++ to http://localhost:8080/mysite
🎭 Volto started at 0.0.0.0:3010 🚀

And i don't see the rewrite of ++api++ to your backend, which should be part of your nginx configuration.

location ~ /\+\+api\+\+($|/.*) {
      rewrite ^/(\+\+api\+\+\/?)+($|/.*) /VirtualHostBase/http/$server_name/mysite/++api++/VirtualHostRoot/$2 break;
      proxy_pass http://backend;
  }

Please keep in mind the frontend will connect to the backend through your reverse proxy, i struggled at that point.

Thanks @claus. I did have a rewrite rule in there but it was obviously incorrect because I replaced it with your suggestion and the :nulls have disappeared!. I still get the resolveuid 404 in the console but I'll tackle that another day.

@claus I had to make one mod to get your rewrite to work properly, change the http to https.

location ~ /\+\+api\+\+($|/.*) {
      rewrite ^/(\+\+api\+\+\/?)+($|/.*) /VirtualHostBase/https/$server_name/mysite/++api++/VirtualHostRoot/$2 break;
      proxy_pass http://backend;
  }
1 Like