How do I update an existing VirtualHost with updated configuration?

 
Solved Solved
1 1 659
1 ACCEPTED SOLUTION

Here is a sample command to add a VirtualHost:

curl -u $USERID:$PASSWORD -X POST http://<MANAGEMENT_SERVER>:<MANAGEMENT_PORT>/v1/o/<org>/e/<env>/virtualhosts -H "Content-Type: application/xml" -d @/tmp/default.xml  

With this XML saved in /tmp/default.xml:

<VirtualHost name="default"> 
<HostAliases> 
<HostAlias>api.example.com</HostAlias> 
</HostAliases> 
<Interfaces/> 
<Port>80</Port> 
</VirtualHost> 

If the "default" VirtualHost already exists, you will receive an error message like the following:

{ 
"code": "messaging.config.beans.VirtualHostAlreadyExists", 
"message": "Virtual host default already exists in environment <ENV>", 
"contexts": [] 
} 

In order to update the existing VirtualHost, you simply need to append the name to the end of the URL when you do your POST. For example:

curl -u $USERID:$PASSWORD -X POST http://<MANAGEMENT_SERVER>:<MANAGEMENT_PORT>/v1/o/<org>/e/<env>/virtualhosts/default -H "Content-Type: application/xml" -d @/tmp/default.xml  

Thanks.

View solution in original post

1 REPLY 1

Here is a sample command to add a VirtualHost:

curl -u $USERID:$PASSWORD -X POST http://<MANAGEMENT_SERVER>:<MANAGEMENT_PORT>/v1/o/<org>/e/<env>/virtualhosts -H "Content-Type: application/xml" -d @/tmp/default.xml  

With this XML saved in /tmp/default.xml:

<VirtualHost name="default"> 
<HostAliases> 
<HostAlias>api.example.com</HostAlias> 
</HostAliases> 
<Interfaces/> 
<Port>80</Port> 
</VirtualHost> 

If the "default" VirtualHost already exists, you will receive an error message like the following:

{ 
"code": "messaging.config.beans.VirtualHostAlreadyExists", 
"message": "Virtual host default already exists in environment <ENV>", 
"contexts": [] 
} 

In order to update the existing VirtualHost, you simply need to append the name to the end of the URL when you do your POST. For example:

curl -u $USERID:$PASSWORD -X POST http://<MANAGEMENT_SERVER>:<MANAGEMENT_PORT>/v1/o/<org>/e/<env>/virtualhosts/default -H "Content-Type: application/xml" -d @/tmp/default.xml  

Thanks.