Search code examples
wso2wso2-api-manager

WSO2 API Manager 4.2.0 - 404 redirects to /carbon page. Can this be reconfigured?


Configuration:

  • API Manager 4.2.0 on linux.
  • NGINX configured for reverse proxy.
  • The API-M portals (https://proxy-hostname/publisher/, /devportal/, /admin/, /console/) are working.
  • Navigating to the root domain (https://proxy-hostname/) redirects to publisher portal (https://proxy-hostname/publisher/) - as expected.

Navigating to a page that does not exist (e.g. https://proxy-hostname/test/) redirects to the carbon admin console (https://proxy-hostname/carbon/admin/login.jsp)

We do not wish end users to be directed towards the admin console if they enter an incorrect URL.

Question: Is is possible to reconfigure this 404 redirect to a different URL by updating WSO2 API Manager configuration?

Research: I have found two previous (answered) questions:

Can you change the WSO2 root redirect?

WSO2 Application Server will redirect to "/carbon" upon 404 error is expected

These answers suggest editing the repository/conf/carbon.xml file setting.

However, API Manager 4.2.0 configuration process has changed compared to previous product releases, so editing xml files as per these old answers (for previous release versions) will get overritten upon restart.


Solution

  • AFAIK there is no way to do this within the Application layer. The easiest solution is to do this at NGINX. You can whitelist all the contexts you want to allow and add a default block to return an error for all the others.

    Update

    Naginx contexts to whitelist.

    • /devportal
    • /admin
    • /publisher
    • /api
    • /oauth2
    • /oidc
    • /authenticationendpoint
    • /logincontext
    • /commonauth