VirtualHost per environment

We have an apiproxy that we want to deploy to a specific VirtualHost; the issue is that we don't have a mapping for that host for all environments. For the 'test' environment we would just like to use the built in 'secure' VirtualHost. Is is possible to have environment specific configuration for this? I do not see a way to do this.

1 5 377
5 REPLIES 5

No, there is not a way to dynamically assign the virtualhost, or to set the virtual host indirectly, in an api proxy

You have a couple options.

1. Use a pre-processing step in your CI/CD pipeline. I am imagining a script that runs sed/awk/perl, reading the proxy.xml file, and replacing the VirtualHost name with the appropriate value for a given environment. Then the script can produce the bundle zip, import it, then deploy it to the appropriate environment.

2. Create a redundant VirtualHost in the "test" environment, with the same name as the virtualhost that is present in all the other environments.

The first option might be more appropriate if you have other values you'd like to substitute or vary depending on the environment - things like the basepath or ... other values. If you don't have any other things to substitute, then the second option is probably easier.

If you need help with what the script ought to look like, ask another question and we'll provide some suggestions and samples.

Thanks Dino,

We considered the 'pre-processing' option, but would like to avoid that variability if at all possible. I think the second option will have to be our policy. I was not sure if there was a restriction on a VirtualHost having the same host name as the built in VirtualHosts (secure in this case); if this is not an issue we should just be able to reuse the built in DNS entry correct?

TBH I have never created 2 vhosts with the same hostalias; I think you are correct that a name can map to just one vhost. But if you need the same name, you should be able to remove the "secure" vhost. Removing may not be necessary; I was assuming you'd want to use a new name for the new vhost.

something like

hostname environment
api.example.com prod
api-qat.example.com qat
api-test.example.com test

Hi @bryanrall ,

I think the best opetion is to have same VHOST name created in all the ORGS.

Also, in case VHOST names are different in all the orgs, then deployment using MAVEN. apigeetool is a good option as you can dynamically replace the values during the build.

Do you have a sample. I want to achieve the same.