External Nginx in front of Apigee router to expose external DNS

I am trying to configure the external DNS for apigee in order to hide the internal exposed DNS [or Virtual host].

I chose the Nginx for external load balancing and forwarding all requests to Apigee router (by default Nginx component).

Internal API: http://green.api.example.co.uk/proxy-name 
External API: https://blue.example.co.uk/api/proxy-name 

I configured the Nginx and the external DNS is hitting the External Nginx and forwarding the request to Apigee router.

But I am getting the following errors:

Apigee Router errors:

 2017-06-26T05:45:19-04:00 192.xx.xx.xx 192.xx.xx.xx:55879 192.xx.xx.xx:8998 0.002 - - 404 404 438 157GET /p HTTP/1.0 192.xx.xx.xx-10284-308-1 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 green.api.example.co.uk 192.xx.xx.xx - false MP messaging.adaptors.http.flow.ApplicationNotFound -- - - -1 

Nginx Errors:

192.xx.xx.xx - - [26/Jun/2017:05:45:19 -0400] "GET /api/proxy-name HTTP/1.1" 404 157 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36" "-"

Nginx Configuration:

server {
    server_name  blue.example.co.uk;
    listen 443 ssl http2;
	location ~ ^/api/(.).*$ {
		proxy_pass http://192.xx.xx.xx:9001/$1;
		proxy_set_header Host green.api.example.co.uk;
		#proxy_set_header X-Real-IP $remote_addr;
		#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		#proxy_set_header X-Forwarded-Proto $scheme;
	}
}
0 3 650
3 REPLIES 3

Not applicable

@Ashokkumar Ks, Can you also show how your Virtual host config looks like?
Are you able to invoke the API call directly on the router?

Not applicable
@Ashokkumar Ks

Similar issue with Apache LB was discussed at : https://community.apigee.com/questions/39946/apache-load-balancer-in-front-of-apigee-nginx-rout.html

Could you please review the above and let us know if that helps?

There is typo in Nginx.

I updated the below configuration and it started to working fine.

server {
    server_name  blue.example.co.uk;
    listen 443 ssl http2;
	location ~ ^/api/(.*)$ {
	   proxy_pass http://192.xx.xx.xx:9001/$1;
	   proxy_set_header Host green.api.example.co.uk;
           #proxy_set_header X-Real-IP $remote_addr;
           #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           #proxy_set_header X-Forwarded-Proto $scheme;
       }
}