As you can see, the output contains information on which port the response is coming from, as we will start multiple instances of the backend for the proxy.
Start backend services
If you have multiple computers, you can start multiple instances listening on the same port on each computer. Otherwise, start multiple instances that listening to different ports on one computer. Here we will start three instances on the same computer and let them listen to 8081, 8082 and 8083 on HTTPS. Let’s disable the HTTP for now, as it is never used on production.
If you generate the proxy-backend service, you should already have the project on your local light-example-4j/rest/openapi folder. If not, let’s clone the repo and compile it locally.
git clone https://github.com/networknt/light-example-4j.git
To start three instances with different HTTPS ports, we need to overwrite the httpsPort in server.yml, which is located at proxy-backend/src/main/resources/config folder with an external values.yml file. The following is the default one generated based on the config.json file. As you can see, HTTP is disabled, and HTTPS is enabled and listen to port 8443.
# Server configuration---# This is the default binding address if the service is dockerized.ip:0.0.0.0# Http port if enableHttp is true.httpPort:8080# Enable HTTP should be false on official environment.enableHttp:false# Https port if enableHttps is true.httpsPort:8443# Enable HTTPS should be true on official environment.enableHttps:true# Http/2 is enabled by default.enableHttp2:true# Keystore file name in config folder. KeystorePass is in secret.yml to access it.keystoreName:tls/server.keystore# Flag that indicate if two way TLS is enabled. Not recommended in docker container.enableTwoWayTls:false# Truststore file name in config folder. TruststorePass is in secret.yml to access it.truststoreName:tls/server.truststore# Unique service identifier. Used in service registration and discovery etc.serviceId:com.networknt.backend-1.0.0# Flag to enable service registration. Only be true if running as standalone Java jar.enableRegistry:false# environment tag that will be registered on consul to support multiple instances per env for testing.# https://github.com/networknt/light-doc/blob/master/docs/content/design/env-segregation.md# This tag should only be set for testing env, not production. The production certification process will enforce it.# environment: test1