Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: More changes https://github.com/wso2/docs-apim/issues/636

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. 

  1. Open the <API-M<APIM_HOME>/repository/conf/carbon.xml file and set the HostName and MgtHostName property the following properties as shown below.

    Localtabgroup
    Localtab
    activetrue
    idFormat-hostname
    titleFormat
    Code Block
    languagexml
    <HostName>{hostname}</HostName>
    <MgtHostName>{management-hostname}</MgtHostName>
    • {hostname} - Hostname or IP address of the machine hosting this server. This

    is will become
    • becomes part of the

    End Point Reference
    • endpoint reference of the services deployed on this server instance.

    • {management-hostname} - Hostname

    to be
    • that is used for the WSO2 API-M Management console.

    Localtab
    idexample-hostname
    titleExample
    Code Block
    languagexml
    <HostName>am.dev.wso2.com</HostName>
    <MgtHostName>am.dev.wso2.com</MgtHostName>
    Generate a key store by following the sub steps given below.
  2. 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. 

    1. Configure the Store URL, which is used to access the Store web app from the Publisher application. 

      Localtabgroup
      active
      Localtab
      trueidFormat-storeURL
      titleFormat
      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 certificates
      languagexml
      <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
      idexample-storeURL
      titleExample
      Code Block
      keytool -genkey -alias am.dev.wso2.com -keyalg RSA -keystore apimkey.jks -keysize 2048
    2. Specify a preferred KeyStore password once prompted.
    3. Specify a preferred Key password once prompted.
    4. Enter the first name and last name as follows once prompted.

      Code Block
      *.am.dev.wso2.com
    5. Enter values for the other parameters as required. 
    Once this information is submitted, a key store is generated with a private key and a public certificate with am.dev.wso2.com as the CN.
  3. Copy the generated self-signed key store (i.e., apimkey.jks) to the <API-M_HOME>/repository/resources/security directory.
  4. Export the public certificate from the keystore and import that certificate to the  client­-truststore.jks  file following the steps given below.
  5. Navigate to the <API-M_HOME>/repository/resources/security directory.
  6. 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> 
  7. Issue the following command to import the certificate to the client­-truststore.jks file.

    Code Blockkeytool -import -alias am.dev.wso2.com -file am.dev.wso2.com -keystore client-truststore.jks -storepass wso2carbon
    1. languagexml
      <APIStore>
              <!--GroupingExtractor>org.wso2.carbon.apimgt.impl.DefaultGroupIDExtractorImpl</GroupingExtractor-->
              ...
              <URL>https://store.wso2.com</URL>
      		...
      </APIStore>
    2. Configure the Publisher URL, which is the URL that is used to access the tenant Store and public Store.

      Localtabgroup
      Localtab
      idFormat-publisherURL
      titleFormat
      Code Block
      languagexml
          <APIPublisher>
              ...
              <URL>https://[mgt-transport-https-hostname]:[mgt-transport-https-port]/publisher</URL>
      		...
          </APIPublisher>
      Localtab
      idexample-publisherURL
      titleExample
      Code Block
      languagexml
          <APIPublisher>
              ...
              <URL>https://publisher.wso2.com</URL>
      		...
          </APIPublisher>
    3. 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
      idFormat-APIURL
      titleFormat
      Code Block
      languagexml
          <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
      idexample-apiURL
      titleExample
      Code Block
      languagexml
          <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>
  8. 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.

Whats Next?


Info
iconfalse

After changing your hostname and management hostname, make sure to whitelist your hostname for the API Store.