APISIX Setup
Finmars APISIX Setup Guide
Abstract
As result of that instruction you will have proxy to Exante Broker e.g. https://exante-proxy.client.com where client.com your domain
Prerequisites
Before starting make sure you have the following:
- Setting up AWS EC2 with Ubuntu, Docker, and a Public IP
- A machine running Linux with Ubuntu 22.04.
- Docker installed on your machine.
- A public IP address.
- Generated API keys in Exante Account Page
Steps to Set Up APISIX
- Run command to add your user to docker group to execute commands:
You need to relogin to VM:sudo usermod -a -G docker $USER
And connect again. To check if it's in effect, run to see current docker images:exit
docker ps
- Create the apisix.yaml Configuration File with your desired configuration:
- Run command to create a file:
nano apisix.yaml
- Copy paste content of the yaml script below.
- You need to replace
- Run command to create a file:
- Run the APISIX Docker Container:
docker run -d --name apache-apisix -p 9080:9080 -p 9443:9443 -e APISIX_STAND_ALONE=true apache/apisix
- Copy the
<strong class="editor-theme-bold editor-theme-code">apisix.yaml</strong>
File to the APISIX Container:docker cp apisix.yaml apache-apisix:/var/tmp/
- Move the
<strong class="editor-theme-bold editor-theme-code">apisix.yaml</strong>
File to the APISIX Configuration Directory:docker exec -i apache-apisix sh -c 'cp /var/tmp/apisix.yaml /usr/local/apisix/conf/'
- Reload the APISIX Configuration:
docker exec -it apache-apisix apisix reload
Setting Up HTTPS
If you want your APISIX instance to listen for HTTPS connections, follow these additional steps:
- Obtain an SSL Certificate:
Get or create an SSL certificate and export it along with its private key to PEM format. - Update
<strong class="editor-theme-bold editor-theme-code">ssls.yaml</strong>
**:**
Put the PEM contents into the corresponding sections of<span class="editor-theme-code">ssls.yaml</span>
. - Include SSL Configuration in
<strong class="editor-theme-bold editor-theme-code">apisix.yaml</strong>
**:**
Add the contents of<span class="editor-theme-code">ssls.yaml</span>
to<span class="editor-theme-code">apisix.yaml</span>
before the<span class="editor-theme-code">#END</span>
instruction.
apisix.yaml file content:
apisix:
node_listen: 9080 # HTTP inbound port
ssl:
enable: true
listen:
- port: 9443 # HTTPS inbound port
enable_http3: false
consumers:
- username: finmars # client name
plugins:
basic-auth:
username: ***YOUR_USERNAME*** # inbound credentials, that you will pass to Finmars IT Team
password: ***YOUR_PASSWORD***
# upstream.yaml
upstreams:
- id: 1
nodes:
api-demo.exante.eu:443: 1
scheme: https
pass_host: node
type: roundrobin
- id: 2
nodes:
api-live.exante.eu:443: 1
scheme: https
pass_host: node
type: roundrobin
# plugin_config.yaml
plugin_configs:
- id: 1
plugins:
basic-auth: {}
proxy-rewrite:
headers:
set: # credentials used to connect to api-demo.exante.eu # Basic Auth string from API key and Secret Key
Authorization: "Basic ***YOUR_BASE64_TOKEN***"
regex_uri:
- "^/demo/(.*)"
- "/$1"
- id: 2
plugins:
basic-auth: {}
proxy-rewrite:
headers:
set: # credentials used to connect to api-live.exante.eu # Basic Auth string from API key and Secret Key
Authorization: "Basic ***YOUR_BASE64_TOKEN***"
regex_uri:
- "^/live/(.*)"
- "/$1"
# routes.yaml
routes:
- uris:
- /demo/md/*/accounts
- /demo/md/*/symbols/*
- /demo/md/*/summary/*
- /demo/md/*/ohlc/*
- /demo/md/*/transactions
- /demo/trade/*/orders/*
upstream_id: 1
plugin_config_id: 1
- uris:
- /live/md/*/accounts
- /live/md/*/symbols/*
- /live/md/*/summary/*
- /live/md/*/ohlc/*
- /live/md/*/transactions
- /live/trade/*/orders/*
upstream_id: 2
plugin_config_id: 2
#END
How To Test
Make a CURL request to APISIX proxy
curl -u foo:bar 0.0.0.0:9080/demo/md/3.0/accounts
or open <span class="editor-theme-code">0.0.0.0.9080/demo/md/3.0/accounts</span>
in browser and pass Basic Auth Credentials
Get help
- APISIX Documentation [https://apisix.apache.org/docs/apisix/getting-started/README/]
- Exante Documentation [https://api-live.exante.eu/api-docs/]
- Finmars IT Help: s.zhitenev@finmars.com