Skip to main content

Version: latest

Proxy Requests to External Services

In this guide, you will learn how to configure routing to external services hosted outside the Kubernetes cluster using the Ingress Controller.

Prerequisite

  1. Complete Set Up Ingress Controller and Gateway.

Create a Route

Create a Kubernetes manifest file for a route that proxies requests to httpbin.org:

httpbin-route.yaml
apiVersion: v1
kind: Service
metadata:
namespace: aic
name: httpbin-external-domain
spec:
type: ExternalName
externalName: httpbin.org
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
namespace: aic
name: httpbin-ip
spec:
parentRefs:
- name: apisix
rules:
- matches:
- path:
type: Exact
value: /ip
backendRefs:
- name: httpbin-external-domain
port: 80

Apply the configurations to your cluster:

kubectl apply -f httpbin-route.yaml

Verify

Expose the gateway’s service port to your local machine:

# replace with your gateway’s service name
kubectl port-forward svc/<gateway-service-name> 9080:80 &

Send a request to the route:

curl "http://127.0.0.1:9080/ip"

You should see a response similar to the following:

{
"origin": "183.94.122.205"
}
API7.ai Logo

The digital world is connected by APIs,
API7.ai exists to make APIs more efficient, reliable, and secure.

Sign up for API7 newsletter

Product

API7 Gateway

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2025. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the Apache Software Foundation