Expose API without mentioning ports

Not applicable

I want to expose some Apis in Edge .I do not want client to know the apigee machine and port number .

SO how do i use virtual hosts in this case. Does this configuration happen at the time of environment creation on edge .

1 9 1,338
9 REPLIES 9

@Arpit Sharma , Above question is related to Private Cloud / Apigee Edge Cloud ? Yes, You need to configure virtual hosts to expose api endpoint as a hostaliasname instead of ip followed by port number. Apigee Edge Private Cloud operations guide helps you configure same. I believe in Apigee Edge cloud you need to work with Apigee Support. Keep us posted if you have any further queries.

adas
New Member

@Arpit Sharma Let me explain a little bit in detail about the concept of virtualhosts. In edge, virtualhosts are configured as domains to which your proxies are deployed. Once the proxy is deployed, the api endpoint becomes a combination of the virtualhost's host alias and the proxy basepath. So if your virtualhost hostalias is configured as api.mydomain.com and your proxy basepath is /v1/myapis, then your API endpoint would be:

http(s)://api.mydomain.com/v1/myapis

Note that the scheme would be http or https depending on how you have configured your virtualhost. To get more details about virtualhosts please refer to our docs page: http://docs.apigee.com/api-services/content/virtual-hosts

Now coming back to your question, it does seem like you are referring to private cloud because in Apigee's public cloud offering, your virtualhosts are configured by out of the box as {org}-{env}.apigee.net for each env with "default" (http) and "secure" (https) when your org is provisioned. The DNS is automatically registered and you get the domain name as mentioned above. In the private cloud, its upto you how you want to configure the virtualhosts. Let me take an example,

Say your router IP is 54.80.129.10. So you could create a virtualhost called "default" in your "test" environment with the port configured as 9001. This is what the setup script included with the private cloud installer does. Now if you want to replace this with a DNS name like "api.mycompany.com", you are free to do that. Once you have a DNS created and mapped to the router IP, you could modify the virtualhost's hostalias with that DNS name, so that your API endpoints would take the same form like I mentioned above in my very first example. I hope I was able to answer your query. Please let me know, if you have any more questions.

@arghya das mapping alias to ip is fine . i did that .But how to map port here .in your example how are you making sure that api.company.com lands on 54.80.129.10:9000?

@Arpit Sharma You will have a load balancer sitting in front which is mapped to the api.company.com DNS and then it would forward request to your routers on port 9000.

@Arpit Sharma

Please go through the below link.

Read the answer/comment posted by me.

https://community.apigee.com/questions/20330/api-proxy-throws-400-error.html#comment-20351

In case of any doubts, please let me know

@Arpit Sharma

Create a VirtualHost and give the port no as 80, then you need to port number. For the Client you just need to provide the hostAliases that you created for the VirtualHost

Ex:

{ "hostAliases": [ "xxxxx.xxx.xxxx.com" ], "interfaces": [], "name": "default", "port": "80" }

You just need to provide the 'xxxxx.xxx.xxxx.com' as the base URL to the Client

Not applicable

I am not sure if anybody here is getting my question

I would try to put an example ,so that it becomes dead simple .

Assumptions :

1. i am using AIO profile of mangement server.

2. i have configured one org,one environment,one virtual host .

My proxy details :

1.Deployment url is http://target.api.com:9020/getWeatherData(i do not unds this as i have configured a virtual host )

2.My virtual Host configuration is :

{ "hostAliases": [ "target.api.com" ], "interfaces": [], "name": "myVirtualHost", "port": "9020" }

3.Base path is "/getWeatherData"

APIGEE doc in context of virtual host says configure DNS entry for router and port ,i do not understand what they mean .All i have done is put following entry in C:\Windows\System32\drivers\etc\hosts file :

mymahineip target.api.com

Now please tell me how can a user access this api as http://target.api.com/getWeatherData

Is there a way ?i do not want to expose port ,neither do i want to use default port 80.

Not applicable

@Arpit Sharma

The default port for http is port 80.So when u say you want to use

http://target.api.com/getWeatherData you actually mean

http://target.api.com:80/getWeatherData .

From your virtual host configuration you have configured your virtual host "myVirtualHost" to listin on port 9020. When you do that a virtual host port is exposed on 9020 on the router (listing for requests on port 9020).

If you donot want to use 9020 in your request URL then

a) use/create a different virtual host that uses port 80

b) Have a load balancer in front of the router and have a rule that takes a request hitting port 80 on the load balancer and forward it to port 9020 of the router

So now your request would look like http://target.api.com/getWeatherData

@arghya das

I am facing similar issue with private cloud installation. I have setup the alias as "myapi.domain.com" without any port in the alias. VHOST_PORT=9001, VHOST_ALIAS=myapi.domain.com, VHOST_NAME=default is set. when proxy is deployed it still shows port in overview tab http://myapi.domain.com:9001/<path>. My understanding is it should not show the port. I am expecting http://myapi.domain.com/<path>; . Is there any additional setup required.