Default URL for API Manager Store is https://<hostname>:9443/store. Instead of that you can use a URL like https://store.wso2apps.com to access the Store.
Setting up a custom URL for Store:
To enable the custom URL using a reverse proxy you need to install nginx. To install nginx and setup SSL certificates you can follow.
http://sanjeewamalalgoda.blogspot.com/2014/12/configure-wso2-api-manager-with-reverse.html
Installing Nginx:
sudo apt-get install nginx
Creating a SSL certificate:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
Go to <APIM_HOME>/repository/resources/security folder using terminal.
Then use following command to add the certificate in to client trust store.
keytool -import -file /etc/nginx/ssl/nginx.crt1 -keystore client-truststore.jks -storepass wso2carbon -alias wso2carbon2
Use the following command to open nginx configuration in gedit.
sudo gedit /etc/nginx/sites-enabled/default
Add the following configuration:
You can use a host name you like such as "store.api.com" which I have used here.
You need to have put it in your /etc/hosts. For example you if you need to name your host as "store.apim.com" add the following entry to /etc/hosts file. Replace the IP with your computer's IP.
10.100.7.77 store.apim.com
To start nginx use the following command.
sudo /etc/init.d/nginx start
After that start the server and go to "https://store.apim.com/" url from the browser and you can see it will directly go to the tenant store.
Few things to take a note:
- proxy_set_header X-WSO2-Tenant "ten5.com";
- This a WSO2 specific header we set to specify the tenant the custom URL should apply. Not like the normal store (which will show all the tenants when go to the store) it will directly go to the specified tenant in the header.
- proxy_redirect https://store.apim.com/store/ /; and proxy_redirect https://localhost:9443/store/ /;
- This need to be set to re-write the location header to the correct URL when the server send HTTP re-directions to the browser.
Configuring Store web app
Add following setting to site.conf of store webapp."reverseProxy" : {
"enabled" : "auto", // values true , false , "auto" - will look for X-Forwarded-* headers
"host" : "sample.proxydomain.com", // If reverse proxy do not have a domain name use IP
"context":"",
"tenantHeader" : "X-WSO2-Tenant"
}
Setup custom domain mapping in registry
You can change the gateway URL appears in store swagger as per your own domain. What you need to do is, configuring custom domain mapping for gateway in super tenant registry following manner.
Login to carbon management console as admin@carbon.super
Create a new resource in following path: (Resource name is the tenant domain name. In my example, ten1.com)
_system/governance/customurl/api-cloud/ten1.com
Add the following content:
{
"tenantDomain": "ten1.com
"store" : {
"customUrl" : "store.apim.com" // custom domain for store
},
"gateway" : {
"customUrl" : "gw.apim.com" // custom domain for gateway
}
}
This is how this would look like in management console.
Now you can see the custom URLs appears in swagger console instead of the default gateway URL.
Once you create an API and publishing it from tenant's Publisher, you can see following dialog appears. If you click on Goto API Store, you will also observe that you will go to your custom store domain; not the default store URL. This is actually redirecting to what you have configured in "customDomain" before.