Monday, May 18, 2015

WSO2 API Manager - Images are not visible in the Store and Publisher

The Issue.

The thumbnails and images that are uploaded are not shown in the publisher or store.

What to note.

In general store reources are accessed with a cotext with the store prefix as follows

http://localhost:9443/store/<ResourcePath>

But since publisher and store shares the common images which are stores in the registry, when retrieving these resources like thumbnails they are accessed directly fro the registry it self. So the Store and Publisher context it not amended to  the URL.

e.g :
In super Tenant Environment

http://localhost:9443/registry/resource/_system/governance/apimgt/applicationdata/icons/admin/testApi/1.0/icon

In Tenant environment

http://localhost:9443/t/test.com/t/test.com/registry/resource/_system/governance/apimgt/applicationdata/icons/admin-AT-test.com/Test/1.0/icon

Possible Reasons for this issue and possible remedies


Scenario 01
  • As mentioned above one possible reason for this issue is when accessing through a reverse proxy there can be some complications and store context can be added by the proxy in some scenarios. Or the resource URL can be changed by the reverse proxy. You can inspect the element and see whats the URL is. Following is a issue I faced, note the URL of the thumbnail.



Then add map the relevent URL pattern from the reverse proxy. Sample Apache2 configs are given below, you can refer the following,
ProxyPass /publisher https://localhost:9443/publisher
ProxyPassReverse /publisher https://localhost:9443/publisher
ProxyPass /carbon https://localhost:9443/carbon
ProxyPassReverse /carbon https://localhost:9443/carbon
ProxyPass /store https://localhost:9443/store
ProxyPassReverse /store https://localhost:9443/store
ProxyPass /registry https://localhost:9443/registry
ProxyPassReverse /registry https://localhost:9443/registry
ProxyPass /t https://localhost:9443/t
ProxyPassReverse /t https://localhost:9443/t
  • From API Manager 1.9 some reverse proxy related configs have been provided, you can refer the following public JIRA as well.


Scenario 02
  • Another possible reason can be authorization issues, when accessing through a LB the domain you are accessing may not be added as a trusted domain, this can happen if there are multiple LBs in place etc. So in order to add the domain as a trusted domain try to access the resource directly via the browser, the browser will prompt and ask whether this needs to be added as a trusted domain and click on add, after adding the domain, you will be able to access these resources successfully.

Hope this will be useful to someone, If you came across some more scenarios please do share, so it may be useful to some else. :)  

3 comments:

  1. Thank you very much Yasassri! Scenario 01 worked for me. I use IIS 8.5 with the Rewrite module as reverse proxy. I already had an inbound rule which redirected the /publisher, /carbon and /store URL's but missed the /registry and /t. So now my match pattern looks like this regex:

    ^(carbon|store|publisher|services|registry|t)(/|\?)?(.*)

    I use multi tenants, so the additional /t did the trick to show the images again.
    Thanks again!

    ReplyDelete
    Replies
    1. Update: The above regex pattern worked for the images, but broke my api back-end routing based on the /t routes. So I had to be more specific to match only URL's with the /icons/ pattern in it, like so:

      ^(carbon|store|publisher|services|registry|(.*/icons))(/|\?)?.*

      Delete
    2. Great to hear that you got your issue sorted :)

      Delete