By default, WSO2 products identify the hostname of the current machine through the Java API. However, this value sometimes yields erroneous results on some environments. Therefore, users are recommended to configure the hostname. The following procedure explains how to change the hostname and management hostname of WSO2 API Manager (WSO2 API-M) as required for your production environment.
Open the
<API-M<APIM_HOME>/repository/conf/carbon.xml
file and set theHostName
andMgtHostName
property the following properties as shown below.
Generate a key store by following the sub steps given below.Localtabgroup Localtab active true id Format-hostname title Format Code Block language xml <HostName>{hostname}</HostName> <MgtHostName>{management-hostname}</MgtHostName>
{hostname}
- Hostname or IP address of the machine hosting this server. This
becomes part of the
endpoint reference of the services deployed on this server instance.
{management-hostname}
- Hostname
that is used for the WSO2 API-M Management console.
Localtab id example-hostname title Example Code Block language xml <HostName>am.dev.wso2.com</HostName> <MgtHostName>am.dev.wso2.com</MgtHostName>
- Open a terminal and issue the following command to generate a key store.
Open the
<APIM_HOME>/repository/conf/api-manager.xml
file and set the following properties as shown below.Configure the Store URL, which is used to access the Store web app from the Publisher application.
Localtabgroup activeLocaltab true id Format-storeURL title Format Code Block keytool -genkey -alias <hostname> -keyalg RSA -keystore <key-store> -keysize 2048
<key-store>
- This is the repository that stores the cryptographic keys and certificateslanguage xml <APIStore> <!--GroupingExtractor>org.wso2.carbon.apimgt.impl.DefaultGroupIDExtractorImpl</GroupingExtractor--> ... <URL>https://[mgt-transport-https-hostname]:[mgt-transport-https-port]/store</URL> ... </APIStore>
[mgt-transport-https-port]
- This port is optional, because if you are fronting the Store nodes with a load balancer, you need to enter the load balancer URL as the Store URL as opposed to entering the hostname and port separately.
Localtab id example-storeURL title Example Code Block keytool -genkey -alias am.dev.wso2.com -keyalg RSA -keystore apimkey.jks -keysize 2048
- Specify a preferred KeyStore password once prompted.
- Specify a preferred Key password once prompted.
Enter the first name and last name as follows once prompted.
Code Block *.am.dev.wso2.com
- Enter values for the other parameters as required.
am.dev.wso2.com
as the CN. - Copy the generated self-signed key store (i.e.,
apimkey.jks
) to the<API-M_HOME>/repository/resources/security
directory. - Export the public certificate from the keystore and import that certificate to the
client-truststore.jks
file following the steps given below. - Navigate to the
<API-M_HOME>/repository/resources/security
directory. Issue the following command to export the public certificate from the primary key store
Code Block keytool -export -alias am.dev.wso2.com -file am.dev.wso2.com -keystore apimkey.jks -storepass <keystore_password_given_above>
language xml <APIStore> <!--GroupingExtractor>org.wso2.carbon.apimgt.impl.DefaultGroupIDExtractorImpl</GroupingExtractor--> ... <URL>https://store.wso2.com</URL> ... </APIStore>
Configure the Publisher URL, which is the URL that is used to access the tenant Store and public Store.
Localtabgroup Localtab id Format-publisherURL title Format Code Block language xml <APIPublisher> ... <URL>https://[mgt-transport-https-hostname]:[mgt-transport-https-port]/publisher</URL> ... </APIPublisher>
Localtab id example-publisherURL title Example Code Block language xml <APIPublisher> ... <URL>https://publisher.wso2.com</URL> ... </APIPublisher>
Configure the environment configurations by defining the endpoint URL for both the REST APIs and Web Socket (WS) APIs that are hosted in the API Gateway.
Localtabgroup Localtab id Format-APIURL title Format Code Block language xml <APIGateway> <Environments> <Environment type="[environment-type]" api-console="true"> <!-- Endpoint URLs for the APIs hosted in this API gateway.--> <GatewayEndpoint>http://[http-gateway-hostname]:[http-gateway-nio-port],https://[https-gateway-hostname]:[https-gateway-nio-port]</GatewayEndpoint> <!-- Endpoint of the Websocket APIs hosted in this API Gateway --> <GatewayWSEndpoint>ws://[gateway-hostname]:[gateway-ws-port]</GatewayWSEndpoint> </Environment> </Environments> </APIGateway>
Localtab id example-apiURL title Example Code Block language xml <APIGateway> <Environments> <Environment type="[environment-type]" api-console="true"> <!-- Endpoint URLs for the APIs hosted in this API gateway.--> <GatewayEndpoint>http://gateway.wso2.com,https://gateway.wso2.com</GatewayEndpoint> <!-- Endpoint of the Websocket APIs hosted in this API Gateway --> <GatewayWSEndpoint>ws://gateway.wso2.com</GatewayWSEndpoint> </Environment> </Environments> </APIGateway>
Generate a key store, export the public certificate from the keystore, and import that certificate to the
client-truststore.jks
file.
For more information, see Creating New Keystores in the WSO2 Administration guide.
Issue the following command to import the certificate to the client-truststore.jks
file.
Whats Next?
Info | ||
---|---|---|
| ||
After changing your hostname and management hostname, make sure to whitelist your hostname for the API Store. |