{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
0
Question by Vinay Soni · Sep 16, 2015 at 11:22 AM · 2.6k Views apigee edgepoliciesconfiguration management

How can i configure Environment based Hostname for my proxy.

Lets say we have Dev/Qa environment based API and both environment has separate host name for target end point and there are bunch of host names.

is there any way lets say if i deploy the proxy on 'test' environment it should take Dev hostname and when i deploy the proxy on 'prod' environment it should take Qa hostname?

Comment
Add comment Show 2
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Anil Sagar @ Google ♦♦   · Sep 16, 2015 at 11:27 AM 0
Link

Dear @Vinay Soni

I think Target Servers should answer your queries. Did you get a chance to look at our documentation here & here ?

avatar image Vinay Soni Anil Sagar @ Google ♦♦ · Sep 16, 2015 at 01:18 PM 0
Link

Thanks anil, i didn't look at it yet.. we try to look it now

Close

2 Answers

  • Sort: 
avatar image
1
Best Answer

Answer by arghya das · Sep 16, 2015 at 04:17 PM

@Vinay Soni There are a few options here. The simplest would be to create targets servers with the same name in both test and prod, each referring to the corresponding target hostname that you want. You can refer to the apigee documentation for how to create and use target servers in your proxies: http://apigee.com/docs/management/apis/post/organi...

The other option is to do that in your proxies through either a javascript or conditional route rules because EDGE populates the environment.name flow variable for all runtime requests.

For the javascript option,

var env = context.getVariable("environment.name"))

would give you the environment that the proxy request hit and then based on that you can populate the corresponding target.url in the javascript.

For the conditional route rules, it would be something very similar:

<RouteRule name="test">
        <Condition>(environment.name = "test")</Condition>
        <HTTPTargetConnection>
            <URL>http://test.myapis.com</URL>
        </HTTPTargetConnection>
</RouteRule>
<RouteRule name="prod">
        <Condition>(environment.name = "prod")</Condition>
        <HTTPTargetConnection>
            <URL>http://prod.myapis.com</URL>
        </HTTPTargetConnection>
</RouteRule>
<RouteRule name="prod">
        <HTTPTargetConnection>
            <URL>http://default.myapis.com</URL>
        </HTTPTargetConnection>
</RouteRule>

Either of these approaches would work, but we recommend going by the target servers approach because then your proxy doesn't need all this logic or hardcoded URLs, and you can easily update the target server URLs using the management apis as and when you need.

Comment
Add comment Show 4 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vinay Soni · Oct 20, 2015 at 12:45 PM 0
Link

thanks @arghya das..

i have some requirement where i need host name of my target server in java script.

Can you help me out ?

avatar image arghya das ♦ Vinay Soni · Oct 20, 2015 at 02:49 PM 0
Link

@Vinay Soni just to maintain the community standards and make content easily searchable, can you post this requirement as a new thread instead of combining with the current post. I will answer that once you have made a new post.

avatar image Vinay Soni · Oct 20, 2015 at 02:38 PM 0
Link

Any help ???

avatar image andreacaligiuri · Sep 11, 2017 at 03:14 PM 0
Link

Hi I've tried to use the targetserver solution but i couldn't make it work. I keep receiving a 502 reply from the proxy

avatar image
1

Answer by Anil Sagar @ Google   · Sep 16, 2015 at 11:33 AM

Dear @Vinay Soni ,

Yes, Apigee Supports it out of the box using Target Servers concept. You can manage same using Edge UI Environment Configuration Link under APIs.

Find more about same here and here.

Cheers,

Anil Sagar


screen-shot-2015-09-16-at-50134-pm.png (63.1 kB)
Comment
Add comment Show 3 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vinay Soni · Sep 16, 2015 at 01:56 PM 0
Link

@Anil Sagar I am using javascript policy in my target endpoint there i am modifying target.url.

So how can i retrieve the hostname mentioned in my target server in javascript policy?

avatar image gnanasekaran ♦ Vinay Soni · Sep 16, 2015 at 02:13 PM 0
Link

you don't need to overwrite target.url, Just need to use Targetservers in your TargetEndpoint configuration. Since TargetServer is created for a env, based on the env -- call will be routed to the appropriate Target,

avatar image Vinay Soni gnanasekaran ♦ · Sep 16, 2015 at 02:58 PM 0
Link

@Mukundha Madhavan yes, but i have some requirement where i have to modify target url path, that's why i need javascript policy

Follow this Question

Answers Answers and Comments

32 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Policy Guidelines for specific use cases 1 Answer

How did I open this useful modal dialog box in the Apigee Edge "Develop" tab ? 1 Answer

Is it possible to hold the request for some time before hitting prox url. 1 Answer

ServiceCallout / LocalTargetConnection Always returns http 200 1 Answer

How to handle multiple proxy for exception handling in shared flow? 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges