How to customize NGinx settings by VirtualHost

In an on-premises (customer-managed) installation of Apigee, you may wish to add custom NGinx configurations. If they can be applied to all sites, see here:

https://community.apigee.com/articles/39288/how-to-configure-nginx-with-special-directives-in.html

If you wish to do this at the VirtualHost level, there is a slightly more complex process. It is very similar to the above, with a few extras.

On each router, do the following. IMPORTANT: make sure to replace your Org, Env, and VHost where applicable:

mkdir -p /opt/nginx/vh.customer/ORG.ENV.VHOST 

Create a file like custom-config.conf under /opt/nginx/vh.customer/ORG.ENV.VHOST (this file can be named anything so long as it has a .conf extension).

Add your custom NGinx configurations to /opt/nginx/vh.customer/ORG.ENV.VHOST/custom-config.conf, for example:

recursive_error_pages off; 

At this point, you may wish to add a new folder and custom-config.conf for another VirtualHost. Repeat the above for all VirtualHosts.

Next, edit your CWC file:

vi /opt/apigee/customer/application/router.properties #(make sure it is owned by apigee:apigee after editing) 

Note: there are 3 different VirtualHost types for OPDK installation: "ssl", "ssl2way", and default/non-SSL (this type has no moniker).

Depending on what types of VirtualHosts you have, you will need to add one or all of the following to router.properties. IMPORTANT: the below text is literal; do not replace any values in the below with your actual org/env/vhost:

conf_load_balancing_load.balancing.driver.nginx.server.ssl.template.extra1=include /opt/nginx/vh.customer/${org}.${env}.${vhost}/*.conf;
conf_load_balancing_load.balancing.driver.nginx.server.ssl2way.template.extra1=include /opt/nginx/vh.customer/${org}.${env}.${vhost}/*.conf;
conf_load_balancing_load.balancing.driver.nginx.server.template.extra1=include /opt/nginx/vh.customer/${org}.${env}.${vhost}/*.conf; 

Lastly, restart the edge-router:

apigee-service edge-router restart 

I hope this helps. Thanks.

Comments
James_wang
Participant I

Hello,

Thanks for your information. May I know when do we use extra2, and when do we use extra1? cause I see your answer and below two, All three are used, but y it seems that the number is influential. May I ask when we use no digits and when extra1 or 2? Is there any document for reference?
https://www.googlecloudcommunity.com/gc/Apigee/How-to-access-tls-related-variables-in-4-18-x/td-p/67...

https://www.googlecloudcommunity.com/gc/Cloud-Product-Articles/How-to-configure-NGinx-with-special-d...

For example, if I want to configuration nginx to forward $ssl_client_v_start

 by proxy_set_header. Should I add below configuration in router.properties? thank you.

 

conf_load_balancing_load.balancing.driver.nginx.server.ssl.template.extra2=proxy_set_header...?
Version history
Last update:
‎03-31-2017 06:45 PM
Updated by: