In this blog post, I want to share the process of building a high availability Docker Swarm infrastructure. By utilizing Keepalived, Ceph, Traefik, and Portainer and created a fault-tolerant setup that ensured the reliability and performance from containerized applications. Following is brief of Docker Swarm Diagram.
Continue readingMigrate InfluxDB databases to Docker
I have plenty of machine which running on old ways of Virtual Machine. Recently i’m interested to looking for a simpler, more automated approach to installation rather than install one by one each machine.
Currently i would like to migrate 1 set of Grafana, Influxdb, Prometheus to Docker. I will post more detail about docker later, but for this article i would like to write more specific to migrate from InfluxDB database to Docker.
InfluxDB Databases
First, let’s take a look at the InfluxDB databases. In this example, we are using version 1.8.10, and we have two databases that we want to back up: telegraf and librenms.
To see a list of the available databases, run the following command in the InfluxDB shell:
# influx -host 127.0.0.1 -port 8086
Connected to http://127.0.0.1:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> SHOW DATABASES;
name: databases
name
----
telegraf
_internal
librenms
> exit
#
Backup Databases
Once we’ve identified the databases that want to back up, run the following commands:
# influxd backup -portable -database telegraf ./influxdb-backup/telegraf
# influxd backup -portable -database librenms ./influxdb-backup/librenms
These commands will create portable backups of the databases in the specified directories. After required database backed up, then we can copy the directory using scp to destined docker host.
scp -r /root/influxdb-backup/ root@destination_docker_host:/home/
Restoring Databases
I have built several service related grafana monitoring using docker compose to provision these container.
influxdb:
image: influxdb:1.8.10
container_name: influxdb
ports:
- "8086:8086"
volumes:
- /opt/appdata/influxdb:/var/lib/influxdb
restart: unless-stopped
After container up then we stop the services using docker stop influxdb. Then we create intermediate container that maps the data volume and our backup directory and then enter the container’s shell:
# docker run --rm --detach -v /opt/appdata/influxdb:/var/lib/influxdb -v /home/influxdb-backup/:/backups -p 8086 influxdb:1.8.10
b87c1e0dcfbdc3250e65c9664cae00b39df9493334bb098ba58be54aeec6b281
# docker exec -it blissful_cori /bin/bash
root@b87c1e0dcfbd:/# influxd version
InfluxDB v1.8.10 (git: 1.8 688e697c51fd)
# influxd restore -portable -database telegraf /backups/telegraf
# influxd restore -portable -database librenms /backups/librenms
# exit
Then stop intermediate container and remove then start influxdb container.
docker stop blissful_cori
Now you can log in to the InfluxDB console and verify that the databases have been restored:
root@bb0711aa705e:/# influx -host 127.0.0.1 -port 8086
Connected to http://127.0.0.1:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> SHOW DATABASES;
name: databases
name
----
_internal
telegraf
librenms
>
Note that you should also check the InfluxDB version on the existing and new systems to ensure compatibility.
References :
https://dev.to/thibmaek/-migrating-influxdb-databases-to-docker-compose-2kee
NGINX Reverse and Forward Proxies
NGINX Layer 4 Proxy
NGINX is a popular open-source web server and reverse proxy that is known for its high performance and flexibility. It is often used as a load balancer or as a reverse proxy to distribute incoming traffic across multiple servers or to cache static content. In this article, we will explain the basics of NGINX as a layer 4 (L4) reverse proxy and forward proxy.
What is a Reverse Proxy?
A reverse proxy is a type of server that sits in front of one or more backend servers and acts as a intermediary for incoming requests. It receives requests from clients and forwards them to the appropriate backend server, and then returns the response from the backend server back to the client.
The main advantage of using a reverse proxy is that it can provide additional security and performance benefits. For example, a reverse proxy can hide the IP addresses of the backend servers from clients, and it can also perform tasks such as SSL termination, compression, and caching to offload workload from the backend servers.
What is a Forward Proxy?
A forward proxy is similar to a reverse proxy, but it sits in front of client computers and acts as a intermediary for outgoing requests. It receives requests from clients and forwards them to the appropriate server, and then returns the response back to the client.
Forward proxies are often used to control access to the Internet, or to provide additional security and privacy for clients. For example, a forward proxy can be used to prevent clients from accessing certain websites, or to encrypt the traffic between clients and servers to protect against eavesdropping.
NGINX as a Reverse Proxy
NGINX can be used as a reverse proxy to distribute incoming traffic across multiple servers or to cache static content. To configure NGINX as a reverse proxy, you need to specify the backend servers in the upstream
block, and then use the proxy_pass
directive to forward the incoming requests to the backend servers.
Here is an example configuration for NGINX as a reverse proxy:
upstream backend {
server backend1.example.com;
server backend2.example.com;
}
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
In this example, NGINX will listen for incoming requests on port 80 and forward them to the backend servers specified in the upstream
block.
NGINX as a Forward Proxy
NGINX can also be used as a forward proxy to control access to the Internet or to provide additional security and privacy for clients. To configure NGINX as a forward proxy, you need to use the proxy_pass
directive to forward the outgoing requests to the destination servers.
Here is an example configuration for NGINX as a forward proxy:
server {
listen 8080;
location / {
proxy_pass http://destination.example.com;
}
}
In this example, NGINX will listen for incoming requests on port 8080 and forward them to the destination server specified in the proxy_pass
directive.
In addition to acting as a Layer 4 (L4) reverse proxy and forward proxy, NGINX can also be used as a layer 7 (L7) reverse proxy and forward proxy.
What is a Layer 7 Reverse Proxy?
A layer 7 reverse proxy is a type of reverse proxy that operates at the application layer (layer 7) of the OSI model. This means that it can examine and manipulate the content of the incoming requests and responses, based on the protocols and application-specific rules.
Layer 7 reverse proxies are often used to provide additional security and performance benefits for web applications. For example, a layer 7 reverse proxy can perform tasks such as authentication, rate limiting, and caching based on the content of the incoming requests.
NGINX as a Layer 7 Reverse Proxy
To configure NGINX as a layer 7 reverse proxy, you need to use the proxy_pass
directive to forward the incoming requests to the backend servers, and use various other directives to manipulate the content of the requests and responses.
Here is an example configuration for NGINX as a layer 7 reverse proxy:
upstream backend {
server backend1.example.com;
server backend2.example.com;
}
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
In this example, NGINX will listen for incoming requests on port 80 and forward them to the backend servers specified in the upstream
block. The proxy_set_header
directives are used to manipulate the headers of the incoming requests and pass them to the backend servers.
What is a Layer 7 Forward Proxy?
A layer 7 forward proxy is similar to a layer 7 reverse proxy, but it sits in front of client computers and acts as a intermediary for outgoing requests. It can examine and manipulate the content of the outgoing requests and responses based on the protocols and application-specific rules.
Layer 7 forward proxies are often used to control access to the Internet or to provide additional security and privacy for clients. For example, a layer 7 forward proxy can be used to block access to certain websites, or to encrypt the traffic between clients and servers to protect against eavesdropping.
NGINX as a Layer 7 Forward Proxy
To configure NGINX as a layer 7 forward proxy, you need to use the proxy_pass
directive to forward the outgoing requests to the destination servers, and use various other directives to manipulate the content of the requests and responses.
Here is an example configuration for NGINX as a layer7 forward proxy:
server {
listen 8080;
location / {
proxy_pass http://destination.example.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
In this example, NGINX will listen for incoming requests on port 8080 and forward them to the destination server specified in the proxy_pass
directive. The proxy_set_header
directives are used to manipulate the headers of the outgoing requests and pass them to the destination server.
Conclusion
In this article, we explained the basics of NGINX as a reverse proxy and forward proxy. NGINX is a powerful and flexible tool that can be used to examine and manipulate the content of incoming and outgoing requests and responses based on the protocols and application-specific rules. With its high performance and rich feature set, NGINX is a popular choice for web servers and reverse proxies.
Parse Coriant/Tellabs CLI Inventory outputs to csv
In my current project i need to generate inventory output for Coriant/Tellabs. We have hundred device that need to be reported. And the only way that we can do is capturing show hw-inventory in each devices and do manual parsing from these logs.
Continue readingSetup Open VPN Server on Google Cloud Platform
In this article will cover how to install VPN Server on Google Cloud Platform. Since nowadays kids jaman now understand vpn and the related things why they use VPN.
Continue reading