Strapi router - proxy and missing /admin/init path #7845

This discussion has been migrated from our Github Discussion #7845


psmyrdek102d ago

Hi, we’ve managed to configure strapi behind a reverse proxy but instead of login page, I see a loading indicator. Let me explain the setup:

Internally, our path to strapi app context is equal to: http://localhost/cms
Externally, our path is equal to https://PUBLIC_HOST

When I test it locally on simulated proxy, I see:
image
but:
image

I noticed that the issue is about exposing /admin/init with prefix:
image

To setup it properly, I’d need to introduce a prefix on my internal setup - /context/admin/init - but I don’t know how to do that.

My guess is that it’s about routing configuration in strapi-admin - am I correct? Can I change that somehow? Setting the host of admin in server.js does not seem to help.

Responses to the discussion on Github


psmyrdek102d ago

Author

Same as #7310 - I cannot set it up properly


derrickmehaffy102d ago

Collaborator

You will need to strip the prefix before passing the request off to Strapi from the proxy, we have an example of this on our Nginx docs:

https://strapi.io/documentation/v3.x/deployment/nginx-proxy.html#sub-folder-unified

    location /api/ {
        rewrite ^/api/(.*)$ /$1 break;
        proxy_pass http://strapi;

Specifically rewrite ^/api/(.*)$ /$1 break; which removes the prefix /api in the request URI


psmyrdek101d ago

Author

The thing is we cannot strip context on internal load balancer. There are multiple apps using the same LB so I’d like to expose cms on localhost:8080/cms having other apps like localhost:8080/app-x and localhost:8080/app-y sitting next to it. That’s why I’d like to add this prefix to /admin/init route - right now the response is HTML page instead of JSON, just as in the ticket I mentioned.


psmyrdek101d ago

Author

Seems like the goal would be to expose admin backend not on root but on a given prefix so that all the routes like /init or /login are called properly.