Add TLS support to CoAP adapter and all readers (#459)

* Add TLS support to CoAP adapter and all readers

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add new env vars to README files

Add tls env vars to README files for CoAP adapter, WS adapter
and all readers.

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Update all services to exit on invalid TLS env var value

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
This commit is contained in:
Aleksandar Novaković 2018-11-20 12:52:28 +01:00 committed by Drasko DRASKOVIC
parent ee262b9647
commit 8ddd78c818
12 changed files with 215 additions and 74 deletions

View File

@ -13,6 +13,7 @@ import (
"net/http"
"os"
"os/signal"
"strconv"
"strings"
"syscall"
@ -26,6 +27,7 @@ import (
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
const (
@ -36,12 +38,16 @@ const (
defCluster = "127.0.0.1"
defKeyspace = "mainflux"
defThingsURL = "localhost:8181"
defClientTLS = "false"
defCACerts = ""
envLogLevel = "MF_CASSANDRA_READER_LOG_LEVEL"
envPort = "MF_CASSANDRA_READER_PORT"
envCluster = "MF_CASSANDRA_READER_DB_CLUSTER"
envKeyspace = "MF_CASSANDRA_READER_DB_KEYSPACE"
envThingsURL = "MF_THINGS_URL"
envClientTLS = "MF_CASSANDRA_READER_CLIENT_TLS"
envCACerts = "MF_CASSANDRA_READER_CA_CERTS"
)
type config struct {
@ -50,6 +56,8 @@ type config struct {
cluster string
keyspace string
thingsURL string
clientTLS bool
caCerts string
}
func main() {
@ -63,7 +71,7 @@ func main() {
session := connectToCassandra(cfg.cluster, cfg.keyspace, logger)
defer session.Close()
conn := connectToThings(cfg.thingsURL, logger)
conn := connectToThings(cfg, logger)
defer conn.Close()
tc := thingsapi.NewClient(conn)
@ -84,12 +92,19 @@ func main() {
}
func loadConfig() config {
tls, err := strconv.ParseBool(mainflux.Env(envClientTLS, defClientTLS))
if err != nil {
log.Fatalf("Invalid value passed for %s\n", envClientTLS)
}
return config{
logLevel: mainflux.Env(envLogLevel, defLogLevel),
port: mainflux.Env(envPort, defPort),
cluster: mainflux.Env(envCluster, defCluster),
keyspace: mainflux.Env(envKeyspace, defKeyspace),
thingsURL: mainflux.Env(envThingsURL, defThingsURL),
clientTLS: tls,
caCerts: mainflux.Env(envCACerts, defCACerts),
}
}
@ -103,13 +118,27 @@ func connectToCassandra(cluster, keyspace string, logger logger.Logger) *gocql.S
return session
}
func connectToThings(url string, logger logger.Logger) *grpc.ClientConn {
conn, err := grpc.Dial(url, grpc.WithInsecure())
func connectToThings(cfg config, logger logger.Logger) *grpc.ClientConn {
var opts []grpc.DialOption
if cfg.clientTLS {
if cfg.caCerts != "" {
tpc, err := credentials.NewClientTLSFromFile(cfg.caCerts, "")
if err != nil {
logger.Error(fmt.Sprintf("Failed to load certs: %s", err))
os.Exit(1)
}
opts = append(opts, grpc.WithTransportCredentials(tpc))
}
} else {
logger.Info("gRPC communication is not encrypted")
opts = append(opts, grpc.WithInsecure())
}
conn, err := grpc.Dial(cfg.thingsURL, opts...)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
return conn
}

View File

@ -13,6 +13,7 @@ import (
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
gocoap "github.com/dustin/go-coap"
@ -25,6 +26,7 @@ import (
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
broker "github.com/nats-io/go-nats"
)
@ -34,11 +36,15 @@ const (
defNatsURL = broker.DefaultURL
defThingsURL = "localhost:8181"
defLogLevel = "error"
defClientTLS = "false"
defCACerts = ""
envPort = "MF_COAP_ADAPTER_PORT"
envNatsURL = "MF_NATS_URL"
envThingsURL = "MF_THINGS_URL"
envLogLevel = "MF_COAP_ADAPTER_LOG_LEVEL"
envClientTLS = "MF_COAP_ADAPTER_CLIENT_TLS"
envCACerts = "MF_COAP_ADAPTER_CA_CERTS"
)
type config struct {
@ -46,6 +52,8 @@ type config struct {
natsURL string
thingsURL string
logLevel string
clientTLS bool
caCerts string
}
func main() {
@ -63,11 +71,7 @@ func main() {
}
defer nc.Close()
conn, err := grpc.Dial(cfg.thingsURL, grpc.WithInsecure())
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to users service: %s", err))
os.Exit(1)
}
conn := connectToThings(cfg, logger)
defer conn.Close()
cc := thingsapi.NewClient(conn)
@ -108,14 +112,45 @@ func main() {
}
func loadConfig() config {
tls, err := strconv.ParseBool(mainflux.Env(envClientTLS, defClientTLS))
if err != nil {
log.Fatalf("Invalid value passed for %s\n", envClientTLS)
}
return config{
thingsURL: mainflux.Env(envThingsURL, defThingsURL),
natsURL: mainflux.Env(envNatsURL, defNatsURL),
port: mainflux.Env(envPort, defPort),
logLevel: mainflux.Env(envLogLevel, defLogLevel),
clientTLS: tls,
caCerts: mainflux.Env(envCACerts, defCACerts),
}
}
func connectToThings(cfg config, logger logger.Logger) *grpc.ClientConn {
var opts []grpc.DialOption
if cfg.clientTLS {
if cfg.caCerts != "" {
tpc, err := credentials.NewClientTLSFromFile(cfg.caCerts, "")
if err != nil {
logger.Error(fmt.Sprintf("Failed to load certs: %s", err))
os.Exit(1)
}
opts = append(opts, grpc.WithTransportCredentials(tpc))
}
} else {
logger.Info("gRPC communication is not encrypted")
opts = append(opts, grpc.WithInsecure())
}
conn, err := grpc.Dial(cfg.thingsURL, opts...)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
return conn
}
func startHTTPServer(port string, logger logger.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("CoAP service started, exposed port %s", port))

View File

@ -115,7 +115,7 @@ func main() {
func loadConfig() config {
tls, err := strconv.ParseBool(mainflux.Env(envClientTLS, defClientTLS))
if err != nil {
tls = false
log.Fatalf("Invalid value passed for %s\n", envClientTLS)
}
return config{

View File

@ -6,6 +6,7 @@ import (
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
@ -18,6 +19,7 @@ import (
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
const (
@ -29,6 +31,8 @@ const (
defDBPort = "8086"
defDBUser = "mainflux"
defDBPass = "mainflux"
defClientTLS = "false"
defCACerts = ""
envThingsURL = "MF_THINGS_URL"
envLogLevel = "MF_INFLUX_READER_LOG_LEVEL"
@ -38,26 +42,30 @@ const (
envDBPort = "MF_INFLUX_READER_DB_PORT"
envDBUser = "MF_INFLUX_READER_DB_USER"
envDBPass = "MF_INFLUX_READER_DB_PASS"
envClientTLS = "MF_INFLUX_READER_CLIENT_TLS"
envCACerts = "MF_INFLUX_READER_CA_CERTS"
)
type config struct {
ThingsURL string
LogLevel string
Port string
DBName string
DBHost string
DBPort string
DBUser string
DBPass string
thingsURL string
logLevel string
port string
dbName string
dbHost string
dbPort string
dbUser string
dbPass string
clientTLS bool
caCerts string
}
func main() {
cfg, clientCfg := loadConfigs()
logger, err := logger.New(os.Stdout, cfg.LogLevel)
logger, err := logger.New(os.Stdout, cfg.logLevel)
if err != nil {
log.Fatalf(err.Error())
}
conn := connectToThings(cfg.ThingsURL, logger)
conn := connectToThings(cfg, logger)
defer conn.Close()
tc := thingsapi.NewClient(conn)
@ -69,7 +77,7 @@ func main() {
}
defer client.Close()
repo := newService(client, cfg.DBName, logger)
repo := newService(client, cfg.dbName, logger)
errs := make(chan error, 2)
go func() {
@ -78,40 +86,61 @@ func main() {
errs <- fmt.Errorf("%s", <-c)
}()
go startHTTPServer(repo, tc, cfg.Port, logger, errs)
go startHTTPServer(repo, tc, cfg.port, logger, errs)
err = <-errs
logger.Error(fmt.Sprintf("InfluxDB writer service terminated: %s", err))
}
func loadConfigs() (config, influxdata.HTTPConfig) {
tls, err := strconv.ParseBool(mainflux.Env(envClientTLS, defClientTLS))
if err != nil {
log.Fatalf("Invalid value passed for %s\n", envClientTLS)
}
cfg := config{
ThingsURL: mainflux.Env(envThingsURL, defThingsURL),
LogLevel: mainflux.Env(envLogLevel, defLogLevel),
Port: mainflux.Env(envPort, defPort),
DBName: mainflux.Env(envDBName, defDBName),
DBHost: mainflux.Env(envDBHost, defDBHost),
DBPort: mainflux.Env(envDBPort, defDBPort),
DBUser: mainflux.Env(envDBUser, defDBUser),
DBPass: mainflux.Env(envDBPass, defDBPass),
thingsURL: mainflux.Env(envThingsURL, defThingsURL),
logLevel: mainflux.Env(envLogLevel, defLogLevel),
port: mainflux.Env(envPort, defPort),
dbName: mainflux.Env(envDBName, defDBName),
dbHost: mainflux.Env(envDBHost, defDBHost),
dbPort: mainflux.Env(envDBPort, defDBPort),
dbUser: mainflux.Env(envDBUser, defDBUser),
dbPass: mainflux.Env(envDBPass, defDBPass),
clientTLS: tls,
caCerts: mainflux.Env(envCACerts, defCACerts),
}
clientCfg := influxdata.HTTPConfig{
Addr: fmt.Sprintf("http://%s:%s", cfg.DBHost, cfg.DBPort),
Username: cfg.DBUser,
Password: cfg.DBPass,
Addr: fmt.Sprintf("http://%s:%s", cfg.dbHost, cfg.dbPort),
Username: cfg.dbUser,
Password: cfg.dbPass,
}
return cfg, clientCfg
}
func connectToThings(url string, logger logger.Logger) *grpc.ClientConn {
conn, err := grpc.Dial(url, grpc.WithInsecure())
func connectToThings(cfg config, logger logger.Logger) *grpc.ClientConn {
var opts []grpc.DialOption
if cfg.clientTLS {
if cfg.caCerts != "" {
tpc, err := credentials.NewClientTLSFromFile(cfg.caCerts, "")
if err != nil {
logger.Error(fmt.Sprintf("Failed to load certs: %s", err))
os.Exit(1)
}
opts = append(opts, grpc.WithTransportCredentials(tpc))
}
} else {
logger.Info("gRPC communication is not encrypted")
opts = append(opts, grpc.WithInsecure())
}
conn, err := grpc.Dial(cfg.thingsURL, opts...)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
return conn
}

View File

@ -14,6 +14,7 @@ import (
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
@ -26,6 +27,7 @@ import (
"github.com/mongodb/mongo-go-driver/mongo"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
const (
@ -35,6 +37,8 @@ const (
defDBName = "mainflux"
defDBHost = "localhost"
defDBPort = "27017"
defClientTLS = "false"
defCACerts = ""
envThingsURL = "MF_THINGS_URL"
envLogLevel = "MF_MONGO_READER_LOG_LEVEL"
@ -42,6 +46,8 @@ const (
envDBName = "MF_MONGO_READER_DB_NAME"
envDBHost = "MF_MONGO_READER_DB_HOST"
envDBPort = "MF_MONGO_READER_DB_PORT"
envClientTLS = "MF_MONGO_READER_CLIENT_TLS"
envCACerts = "MF_MONGO_READER_CA_CERTS"
)
type config struct {
@ -51,6 +57,8 @@ type config struct {
dbName string
dbHost string
dbPort string
clientTLS bool
caCerts string
}
func main() {
@ -59,7 +67,8 @@ func main() {
if err != nil {
log.Fatalf(err.Error())
}
conn := connectToThings(cfg.thingsURL, logger)
conn := connectToThings(cfg, logger)
defer conn.Close()
tc := thingsapi.NewClient(conn)
@ -82,6 +91,11 @@ func main() {
}
func loadConfigs() config {
tls, err := strconv.ParseBool(mainflux.Env(envClientTLS, defClientTLS))
if err != nil {
log.Fatalf("Invalid value passed for %s\n", envClientTLS)
}
return config{
thingsURL: mainflux.Env(envThingsURL, defThingsURL),
logLevel: mainflux.Env(envLogLevel, defLogLevel),
@ -89,6 +103,8 @@ func loadConfigs() config {
dbName: mainflux.Env(envDBName, defDBName),
dbHost: mainflux.Env(envDBHost, defDBHost),
dbPort: mainflux.Env(envDBPort, defDBPort),
clientTLS: tls,
caCerts: mainflux.Env(envCACerts, defCACerts),
}
}
@ -102,13 +118,27 @@ func connectToMongoDB(host, port, name string, logger logger.Logger) *mongo.Data
return client.Database(name)
}
func connectToThings(url string, logger logger.Logger) *grpc.ClientConn {
conn, err := grpc.Dial(url, grpc.WithInsecure())
func connectToThings(cfg config, logger logger.Logger) *grpc.ClientConn {
var opts []grpc.DialOption
if cfg.clientTLS {
if cfg.caCerts != "" {
tpc, err := credentials.NewClientTLSFromFile(cfg.caCerts, "")
if err != nil {
logger.Error(fmt.Sprintf("Failed to load certs: %s", err))
os.Exit(1)
}
opts = append(opts, grpc.WithTransportCredentials(tpc))
}
} else {
logger.Info("gRPC communication is not encrypted")
opts = append(opts, grpc.WithInsecure())
}
conn, err := grpc.Dial(cfg.thingsURL, opts...)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
return conn
}

View File

@ -127,7 +127,7 @@ func main() {
func loadConfig() config {
tls, err := strconv.ParseBool(mainflux.Env(envClientTLS, defClientTLS))
if err != nil {
tls = false
log.Fatalf("Invalid value passed for %s\n", envClientTLS)
}
return config{

View File

@ -96,7 +96,7 @@ func main() {
func loadConfig() config {
tls, err := strconv.ParseBool(mainflux.Env(envClientTLS, defClientTLS))
if err != nil {
tls = false
log.Fatalf("Invalid value passed for %s\n", envClientTLS)
}
return config{

View File

@ -9,12 +9,14 @@ The service is configured using the environment variables presented in the
following table. Note that any unset variables will be replaced with their
default values.
| Variable | Description | Default |
|---------------------------|------------------------|-----------------------|
| MF_COAP_ADAPTER_PORT | Service listening port | 5683 |
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
| MF_THINGS_URL | Things service URL | localhost:8181 |
| MF_COAP_ADAPTER_LOG_LEVEL | Service log level | error |
| Variable | Description | Default |
|----------------------------|------------------------------------------------|-----------------------|
| MF_COAP_ADAPTER_PORT | Service listening port | 5683 |
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
| MF_THINGS_URL | Things service URL | localhost:8181 |
| MF_COAP_ADAPTER_LOG_LEVEL | Service log level | error |
| MF_COAP_ADAPTER_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
| MF_COAP_ADAPTER_CA_CERTS | Path to trusted CAs in PEM format | |
## Deployment
@ -34,6 +36,8 @@ services:
MF_NATS_URL: [NATS instance URL]
MF_THINGS_URL: [Things service URL]
MF_COAP_ADAPTER_LOG_LEVEL: [Service log level]
MF_COAP_ADAPTER_CLIENT_TLS: [Flag that indicates if TLS should be turned on]
MF_COAP_ADAPTER_CA_CERTS: [Path to trusted CAs in PEM format]
```
Running this service outside of container requires working instance of the NATS service.
@ -52,7 +56,7 @@ make coap
make install
# set the environment variables and run the service
MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_COAP_ADAPTER_PORT=[Service HTTP port] MF_COAP_ADAPTER_LOG_LEVEL=[Service log level] $GOBIN/mainflux-coap
MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_COAP_ADAPTER_PORT=[Service HTTP port] MF_COAP_ADAPTER_LOG_LEVEL=[Service log level] MF_COAP_ADAPTER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] MF_COAP_ADAPTER_CA_CERTS=[Path to trusted CAs in PEM format] $GOBIN/mainflux-coap
```
## Usage

View File

@ -8,12 +8,14 @@ The service is configured using the environment variables presented in the
following table. Note that any unset variables will be replaced with their
default values.
| Variable | Description | Default |
|---------------------------------|---------------------------------------------|----------------|
| MF_CASSANDRA_READER_PORT | Service HTTP port | 8180 |
| MF_CASSANDRA_READER_DB_CLUSTER | Cassandra cluster comma separated addresses | 127.0.0.1 |
| MF_CASSANDRA_READER_DB_KEYSPACE | Cassandra keyspace name | mainflux |
| MF_THINGS_URL | Things service URL | localhost:8181 |
| Variable | Description | Default |
|---------------------------------|------------------------------------------------|----------------|
| MF_CASSANDRA_READER_PORT | Service HTTP port | 8180 |
| MF_CASSANDRA_READER_DB_CLUSTER | Cassandra cluster comma separated addresses | 127.0.0.1 |
| MF_CASSANDRA_READER_DB_KEYSPACE | Cassandra keyspace name | mainflux |
| MF_THINGS_URL | Things service URL | localhost:8181 |
| MF_CASSANDRA_READER_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
| MF_CASSANDRA_READER_CA_CERTS | Path to trusted CAs in PEM format | |
## Deployment
@ -30,6 +32,8 @@ default values.
MF_CASSANDRA_READER_PORT: [Service HTTP port]
MF_CASSANDRA_READER_DB_CLUSTER: [Cassandra cluster comma separated addresses]
MF_CASSANDRA_READER_DB_KEYSPACE: [Cassandra keyspace name]
MF_CASSANDRA_READER_CLIENT_TLS: [Flag that indicates if TLS should be turned on]
MF_CASSANDRA_READER_CA_CERTS: [Path to trusted CAs in PEM format]
ports:
- [host machine port]:[configured HTTP port]
```
@ -50,7 +54,7 @@ make cassandra-reader
make install
# Set the environment variables and run the service
MF_THINGS_URL=[Things service URL] MF_CASSANDRA_READER_PORT=[Service HTTP port] MF_CASSANDRA_READER_DB_CLUSTER=[Cassandra cluster comma separated addresses] MF_CASSANDRA_READER_DB_KEYSPACE=[Cassandra keyspace name] $GOBIN/mainflux-cassandra-reader
MF_THINGS_URL=[Things service URL] MF_CASSANDRA_READER_PORT=[Service HTTP port] MF_CASSANDRA_READER_DB_CLUSTER=[Cassandra cluster comma separated addresses] MF_CASSANDRA_READER_DB_KEYSPACE=[Cassandra keyspace name] MF_CASSANDRA_READER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] MF_CASSANDRA_READER_CA_CERTS=[Path to trusted CAs in PEM format] $GOBIN/mainflux-cassandra-reader
```

View File

@ -8,14 +8,16 @@ The service is configured using the environment variables presented in the
following table. Note that any unset variables will be replaced with their
default values.
| Variable | Description | Default |
|---------------------------|-----------------------------------|-----------------------|
| MF_INFLUX_READER_PORT | Service HTTP port | 8180 |
| MF_INFLUX_READER_DB_NAME | InfluxDB database name | mainflux |
| MF_INFLUX_READER_DB_HOST | InfluxDB host | localhost |
| MF_INFLUX_READER_DB_PORT | Default port of InfluxDB database | 8086 |
| MF_INFLUX_READER_DB_USER | Default user of InfluxDB database | mainflux |
| MF_INFLUX_READER_DB_PASS | Default password of InfluxDB user | mainflux |
| Variable | Description | Default |
|-----------------------------|------------------------------------------------|-----------|
| MF_INFLUX_READER_PORT | Service HTTP port | 8180 |
| MF_INFLUX_READER_DB_NAME | InfluxDB database name | mainflux |
| MF_INFLUX_READER_DB_HOST | InfluxDB host | localhost |
| MF_INFLUX_READER_DB_PORT | Default port of InfluxDB database | 8086 |
| MF_INFLUX_READER_DB_USER | Default user of InfluxDB database | mainflux |
| MF_INFLUX_READER_DB_PASS | Default password of InfluxDB user | mainflux |
| MF_INFLUX_READER_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
| MF_INFLUX_READER_CA_CERTS | Path to trusted CAs in PEM format | |
## Deployment
@ -33,6 +35,8 @@ default values.
MF_INFLUX_READER_DB_PORT: [InfluxDB port]
MF_INFLUX_READER_DB_USER: [InfluxDB admin user]
MF_INFLUX_READER_DB_PASS: [InfluxDB admin password]
MF_INFLUX_READER_CLIENT_TLS: [Flag that indicates if TLS should be turned on]
MF_INFLUX_READER_CA_CERTS: [Path to trusted CAs in PEM format]
ports:
- [host machine port]:[configured HTTP port]
```
@ -52,7 +56,7 @@ make influxdb-reader
make install
# Set the environment variables and run the service
MF_THINGS_URL=[Things service URL] MF_INFLUX_READER_PORT=[Service HTTP port] MF_INFLUX_READER_DB_NAME=[InfluxDB database name] MF_INFLUX_READER_DB_HOST=[InfluxDB database host] MF_INFLUX_READER_DB_PORT=[InfluxDB database port] MF_INFLUX_READER_DB_USER=[InfluxDB admin user] MF_INFLUX_READER_DB_PASS=[InfluxDB admin password] $GOBIN/mainflux-influxdb
MF_THINGS_URL=[Things service URL] MF_INFLUX_READER_PORT=[Service HTTP port] MF_INFLUX_READER_DB_NAME=[InfluxDB database name] MF_INFLUX_READER_DB_HOST=[InfluxDB database host] MF_INFLUX_READER_DB_PORT=[InfluxDB database port] MF_INFLUX_READER_DB_USER=[InfluxDB admin user] MF_INFLUX_READER_DB_PASS=[InfluxDB admin password] MF_INFLUX_READER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] MF_INFLUX_READER_CA_CERTS=[Path to trusted CAs in PEM format] $GOBIN/mainflux-influxdb
```

View File

@ -8,13 +8,15 @@ The service is configured using the environment variables presented in the
following table. Note that any unset variables will be replaced with their
default values.
| Variable | Description | Default |
|-------------------------|-----------------------|----------------|
| MF_THINGS_URL | Things service URL | localhost:8181 |
| MF_MONGO_READER_PORT | Service HTTP port | 8180 |
| MF_MONGO_READER_DB_NAME | MongoDB database name | mainflux |
| MF_MONGO_READER_DB_HOST | MongoDB database host | localhost |
| MF_MONGO_READER_DB_PORT | MongoDB database port | 27017 |
| Variable | Description | Default |
|----------------------------|------------------------------------------------|----------------|
| MF_THINGS_URL | Things service URL | localhost:8181 |
| MF_MONGO_READER_PORT | Service HTTP port | 8180 |
| MF_MONGO_READER_DB_NAME | MongoDB database name | mainflux |
| MF_MONGO_READER_DB_HOST | MongoDB database host | localhost |
| MF_MONGO_READER_DB_PORT | MongoDB database port | 27017 |
| MF_MONGO_READER_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
| MF_MONGO_READER_CA_CERTS | Path to trusted CAs in PEM format | |
## Deployment
@ -32,6 +34,8 @@ default values.
MF_MONGO_READER_DB_NAME: [MongoDB name]
MF_MONGO_READER_DB_HOST: [MongoDB host]
MF_MONGO_READER_DB_PORT: [MongoDB port]
MF_MONGO_READER_CLIENT_TLS: [Flag that indicates if TLS should be turned on]
MF_MONGO_READER_CA_CERTS: [Path to trusted CAs in PEM format]
ports:
- [host machine port]:[configured HTTP port]
```
@ -51,7 +55,7 @@ make mongodb-reader
make install
# Set the environment variables and run the service
MF_THINGS_URL=[Things service URL] MF_MONGO_READER_PORT=[Service HTTP port] MF_MONGO_READER_DB_NAME=[MongoDB database name] MF_MONGO_READER_DB_HOST=[MongoDB database host] MF_MONGO_READER_DB_PORT=[MongoDB database port] $GOBIN/mainflux-mongodb-reader
MF_THINGS_URL=[Things service URL] MF_MONGO_READER_PORT=[Service HTTP port] MF_MONGO_READER_DB_NAME=[MongoDB database name] MF_MONGO_READER_DB_HOST=[MongoDB database host] MF_MONGO_READER_DB_PORT=[MongoDB database port] MF_MONGO_READER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] MF_MONGO_READER_CA_CERTS=[Path to trusted CAs in PEM format] $GOBIN/mainflux-mongodb-reader
```

View File

@ -35,6 +35,8 @@ services:
MF_NATS_URL: [NATS instance URL]
MF_WS_ADAPTER_PORT: [Service WS port]
MF_WS_ADAPTER_LOG_LEVEL: [WS adapter log level]
MF_WS_ADAPTER_CLIENT_TLS: [Flag that indicates if TLS should be turned on]
MF_WS_ADAPTER_CA_CERTS: [Path to trusted CAs in PEM format]
```
To start the service outside of the container, execute the following shell script:
@ -52,7 +54,7 @@ make ws
make install
# set the environment variables and run the service
MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_WS_ADAPTER_PORT=[Service WS port] MF_WS_ADAPTER_LOG_LEVEL=[WS adapter log level] $GOBIN/mainflux-ws
MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_WS_ADAPTER_PORT=[Service WS port] MF_WS_ADAPTER_LOG_LEVEL=[WS adapter log level] MF_WS_ADAPTER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] MF_WS_ADAPTER_CA_CERTS=[Path to trusted CAs in PEM format] $GOBIN/mainflux-ws
```
## Usage