Skip to main content

Version: latest

Proxy Requests to a Service

This tutorial shows you how to create a basic route with the Ingress Controller that proxies requests to a sample service running in the cluster and verify that the routing functions correctly.

Prerequisite

  1. Complete Set Up Ingress Controller and Gateway.

Start a Sample Upstream Service

Start an HTTPBIN service named httpbin in the current namespace to use as the sample upstream service:

kubectl apply -f https://raw.githubusercontent.com/apache/apisix-ingress-controller/refs/heads/v2.0.0/examples/httpbin/deployment.yaml

Create a Route

Create a Kubernetes manifest file for a route that will proxy requests to the HTTPBIN sample upstream service:

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

Apply the configurations to your cluster:

kubectl apply -f httpbin-route.yaml

Verify Routing

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 of the following:

{
"origin": "127.0.0.1"
}

Delete the Route

To remove the previously created route, run the following command:

kubectl delete -f httpbin-route.yaml

Next Steps

You have now learned the basics of proxying requests with a route. Next, you will explore the broader capabilities provided by the plugin ecosystem.

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