LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub
Star

Client Proxy Server Proxy

After we have done the server-proxy, we can set up the market API to use the client-proxy to access the petstore API.

Assume that the petstore API and the server-proxy still up and running. The following command can confirm the petstore is working and accessible from the server-proxy.

curl -k https://localhost:7443/v1/pets

And the result should be.

[{"id":1,"name":"catten","tag":"cat"},{"id":2,"name":"doggy","tag":"dog"}]

Client Proxy

Let’s start another light-gateway instance for the client-proxy. The market API will call the client-proxy, the client-proxy will call the server-proxy and then the server-proxy will call the petstore API.

Open another terminal and start the client-proxy.

cd ~/networknt/light-gateway
java -jar -Dlight-4j-config-dir=config/client-proxy-market target/light-gateway.jar

Market API

Let’s start the market API.

cd ~/networknt/light-example-4j/rest/market
java -jar target/server.jar

The server will start and listen to port 6443 on HTTPS/2.

Test Market

curl -k https://localhost:6443/petstore/products

you should have the following result.

[{"id":1,"name":"catten","tag":"cat"},{"id":2,"name":"doggy","tag":"dog"}]

Client Proxy Configuration

The configuration files are located in light-gateway/config/client-proxy-market folder.

handler.yml

Here is the chain for routing only.

chains:
  default:
    - exception
    - metrics
    - traceability
    - correlation
    - cors
    - header
    - router
values.yml
  • server.yml

Set the httpPort to 9080 and give it a serviceId called com.networknt.client-gateway-market

  • router.yml

Allow the hostWhitelist for localhost and set the maxRequestTime to 3 seconds.

  • pathPrefixService.yml

Add /v1/pets to com.networknt.petstore mapping

  • service.yml

Add an entry for petstore to localhost:7443 which is the server proxy of petstore.

com.networknt.petstore: https://localhost:7443

Here is the entire file.

# server.yml
server.httpPort: 9080
server.enableHttp: true
server.enableHttps: false
server.enableHttp2: false
server.serviceId: com.networknt.client-gateway-market

# router.yml
router.maxRequestTime: 3000
router.hostWhitelist:
  - localhost

# pathPrefixService.yml
pathPrefixService.mapping:
  /v1/pets: com.networknt.petstore

# service.yml
service.singletons:
  - com.networknt.registry.URL:
      - com.networknt.registry.URLImpl:
          parameters:
            com.networknt.petstore: https://localhost:7443
  - com.networknt.registry.Registry:
      - com.networknt.registry.support.DirectRegistry
  - com.networknt.balance.LoadBalance:
      - com.networknt.balance.RoundRobinLoadBalance
  - com.networknt.cluster.Cluster:
      - com.networknt.cluster.LightCluster
  - com.networknt.utility.Decryptor:
      - com.networknt.decrypt.AESDecryptor

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Client Proxy Server Proxy” was last updated: April 8, 2022: fixes #328 add gateway service and tutorial (dd1260c)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute