Admin/init returns 404 for split folder reverse proxy

System Information
  • Strapi Version: 4.0.4
  • Operating System: Ubuntu 20.04
  • Database: Postgres
  • Node Version: 16.13.2
  • NPM Version: 8.1.2
  • Yarn Version: 1.22.17

Hi all!

I’ve been struggling trying to get this admin UI to show up on my server. I have a dokku server set up through digital ocean. I’m trying to use nginx to set up a reverse proxy (split subfolder strategy) for strapi so that I can access it from my svelte app without having to host on another server.

I started by trying to set it up with the basic subfolder strategy. I targeted /strapi and set up a reverse proxy in nginx with the following location block:

location    /strapi/ {
    rewrite ^/strapi/?(.*)$ /$1 break;
    proxy_pass  http://strapi-1337;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass_request_headers on;

This location block resides in the same nginx config for my web server hosting the sveltekit app. The upstream block is configured by dokku for me, so I’m utilizing that since the container address is dynamic.

I thought I was successful when I navigated to the /strapi directory and was presented with a status screen saying all is good. I was disappointed to see that /strapi/admin returned a 404. After messing with the server url config option, I gave up and am now trying the split folder strategy.

The split folder strategy led me to what I believe is closer to a real solution. I changed the config for my server and admin so that the admin url is http://myhost/strapi/dashboard and the server url is http://myhost/strapi. This actually loads html on the admin page, but fails to fully load what is needed due to a 404 from http://myhost/strapi/api/admin/init. Can anyone help me figure out how to get the admin panel loaded?

1 Like