Skip to content

Latest commit

 

History

History
72 lines (48 loc) · 1.8 KB

proxy.md

File metadata and controls

72 lines (48 loc) · 1.8 KB
title keywords tags sidebar permalink summary
Service Proxy
proxy
proxy
home_sidebar
/docs/proxy.html
The micro proxy is a service-to-service proxy.

A service proxy is a server which acts as an intermediary for requests from one service to another.

Overview

The micro proxy provides a proxy implementation of the go-micro framework. This consolidates go-micro features into a single location which allows offloading service discovery, load balancing, fault tolerance, plugins, wrappers, etc to the proxy itself. Rather than updating every Go Micro app for infrastructure level concerns, its easier to put them in the proxy. It also allows any language to be integrated with a thin client rather than having to implement all the features.

Run Proxy

Start the proxy

micro proxy

The server address is dynamic but can be configured as follows.

MICRO_SERVER_ADDRESS=localhost:9090 micro proxy

Proxy Services

Now the proxy is running you can quite simply proxy requests through it.

Start your go micro app like so

MICRO_PROXY=go.micro.proxy go run main.go

Your service will lookup the proxy in discovery then use it to route any requests. If multiple proxies exist it will balance it's requests across them. It will also cache the proxy addresses locally.

If you would rather send requests through a single proxy specify it's address like so.

MICRO_PROXY=localhost:9090 go run main.go

Ensure the proxy is running on the address specified.

MICRO_SERVER_ADDRESS=localhost:9090 micro proxy

Single Endpoint

Use the proxy as a front proxy for a single endpoint

MICRO_SERVER_NAME=helloworld \
MICRO_PROXY_ENDPOINT=localhost:10001 \
micro proxy

All requests to helloworld will be sent to the backend at localhost:10001