0% found this document useful (0 votes)
185 views4 pages

Apisix Info

The document provides information about deploying and using Apache APISIX as an API gateway. It describes how to install and run APISIX using Docker, create routes, configure plugins, integrate with service discovery using Eureka, and examples of routing API requests to multiple backend services. Key steps include starting APISIX using docker-compose, creating routes using the admin API, verifying routes on the dashboard, and routing requests to services registered with Eureka for dynamic service discovery.

Uploaded by

srinivas g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views4 pages

Apisix Info

The document provides information about deploying and using Apache APISIX as an API gateway. It describes how to install and run APISIX using Docker, create routes, configure plugins, integrate with service discovery using Eureka, and examples of routing API requests to multiple backend services. Key steps include starting APISIX using docker-compose, creating routes using the admin API, verifying routes on the dashboard, and routing requests to services registered with Eureka for dynamic service discovery.

Uploaded by

srinivas g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

https://apisix.apache.

org/docs/apisix/getting-started/
https://apisix.apache.org/blog/2021/06/28/why-we-need-apache-apisix/

https://dev.to/apisix/3-ways-to-deploy-apache-apisix-on-aws-part-1-aws-ec2-2c86
https://dev.to/apisix/3-ways-to-deploy-apache-apisix-on-aws-part-2-aws-ess-gfi
https://www.youtube.com/watch?v=dUOjJkb61so
https://apache.googlesource.com/apisix/+/refs/tags/1.3/doc/getting-started.md

docker down permission issue:


https://gist.github.com/zenthangplus/4b2d534fa85031ae6c652ffe16ae5da2
https://apisix.apache.org/docs/apisix/plugins/redirect/

web1 and web2 examples:


https://developpaper.com/a-new-generation-of-api-gateway-with-visual-management-
document-friendly/
https://apisix.apache.org/docs/docker/example/

eureka apisix integration:


https://apisix.apache.org/blog/2022/03/05/apisix-integration-eureka-service-
discovery/
https://developpaper.com/api-gateway-apache-apis-ix-integrates-eureka-as-service-
discovery/
https://apisix.apache.org/docs/apisix/next/discovery/

https://dev.to/apisix/centralized-authentication-with-apache-apisix-plugins-30fo

API key: perfiosintegreat


Dashboard username and password:
docker-compose -p docker-apisix up -d
docker-compose -p docker-apisix down

docker exec -it saas-integreat /bin/bash

verify admin api:

curl "http://127.0.0.1:9080/apisix/admin/services/" -H 'X-API-KEY:


perfiosintegreat'

create a route:
curl "http://127.0.0.1:9080/apisix/admin/routes/1" -H "X-API-KEY: perfiosintegreat"
-X PUT -d '
{
"methods": ["GET"],
"host": "example.com",
"uri": "/anything/*",
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}'

curl http://localhost:9080/apisix/admin/routes -H 'X-API-KEY: perfiosintegreat' -X


POST -d '
{
"name": "Route to httpbin",
"uris": ["/demo/*"],
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}'

verify dashboard for created route: http://localhost:9000/routes/list

verify url redirection:

curl -i -X GET "http://127.0.0.1:9080/anything/foo?arg=10" -H "Host: example.com"


curl -i 'http://127.0.0.1:9080/anything?foo=bar&baz' -X POST -d '{ "hello":
"world" }' -H "Host: example.com" 'Content-Type: application/json'

apisix eureka integration:

discovery: # service discovery center

eureka:

host: # it's possible to define multiple eureka


hosts addresses of the same eureka cluster.

- "http://vishal:[email protected]:8761" # access address of


Eureka server started by spring boot
prefix: /eureka/
fetch_interval: 30 # default 30s

weight: 100 # default weight for node

timeout:

connect: 2000 # default 2000ms

send: 2000 # default 2000ms

read: 5000 # default 5000ms

curl http://127.0.0.1:9092/v1/discovery/eureka/dump

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: perfiosintegreat' -


X PUT -i -d '
{
"uri": "/payuservice/*",
"plugins": {
"proxy-rewrite" : {
"regex_uri": ["^/payuservice/(.*)", "/${1}"]
}
},
"upstream": {
"service_name": "P2P-PAYU-GATEWAY-SERVICE",
"type": "roundrobin",
"discovery_type": "eureka"
}
}'

curl http://127.0.0.1:9080/apisix/admin/routes/2 -H 'X-API-KEY: perfiosintegreat' -


X PUT -i -d '
{
"uri": "/payuservice/*",
"plugins": {
"proxy-rewrite" : {
"regex_uri": ["^/payuservice/(.*)", "/${1}"]
}
},
"upstream": {
"service_name": "P2P-PAYU-GATEWAY-SERVICE",
"type": "roundrobin",
"discovery_type": "eureka"
}
}'

curl http://127.0.0.1:9080/apisix/admin/routes/3 -H 'X-API-KEY: perfiosintegreat' -


X PUT -i -d '
{
"uri": "/loanreport/*",
"plugins": {
"proxy-rewrite" : {
"regex_uri": ["^/loanreport/(.*)", "/${1}"]
}
},
"upstream": {
"service_name": "LOANREPORT",
"type": "roundrobin",
"discovery_type": "eureka"
}
}'

curl http://127.0.0.1:9080/apisix/admin/routes/427716274848531210 -H 'X-API-KEY:


perfiosintegreat' -X GET
curl http://127.0.0.1:9080/apisix/admin/upstreams/427716129272627978 -H 'X-API-KEY:
perfiosintegreat' -X GET

while true; do curl http://localhost:9080/api/web1/ ; sleep 0.3; echo; done

while true; do curl http://localhost:9080/api/web2/ ;sleep 1; echo; done


while true; do curl http://api.perfios.com:9080/api/loanreport/generateReport ;
sleep 1; echo; done
while true; do curl http://localhost:9080/api/loanreport/generateReport ; sleep 1;
echo; done

curl http://localhost:9080/loanreport/
curl http://localhost:9080/loanreport/ -H "host: localhost:9080"
curl http://192.168.1.40:9080/loanreport/ -H "host: localhost:9080"

curl http://172.80.19.5:7000/loanreport/ -H "host: localhost:9080"

office ip: 192.168.28.25


192.168.28.67
home ip: 192.168.1.40

local ports:
http://localhost:9081/web1/
http://localhost:9082/web2/
http://localhost:7100/notification
http://localhost:7000/loanreport

http://192.168.1.40:9081/web1/
http://192.168.1.40:9082/web2/
http://192.168.1.40:7100/notification
http://192.168.1.40:7000/loanreport

http://api.perfios.com:9080/api/web1/
http://api.perfios.com:9080/api/web2/
http://api.perfios.com:9080/api/notification/
http://api.perfios.com:9080/api/notification/sendSMS
http://api.perfios.com:9080/api/loanreport/
http://api.perfios.com:9080/api/loanreport/generateReport

You might also like