По директориям раскидал
This commit is contained in:
@ -1,341 +1,341 @@
|
||||
Here’s a step-by-step guide to setting up a **RabbitMQ cluster with replication** correctly:
|
||||
|
||||
---
|
||||
|
||||
## **Step 1: Prepare the Servers**
|
||||
|
||||
Ensure you have at least **three** nodes (recommended for HA) with:
|
||||
|
||||
- Ubuntu 22.04 (or a supported OS)
|
||||
- Sufficient CPU/RAM based on workload
|
||||
- Open necessary firewall ports (**5672, 15672, 25672**)
|
||||
|
||||
Set hostnames for clarity:
|
||||
|
||||
```bash
|
||||
sudo hostnamectl set-hostname rabbitmq-node1 # Change for each node
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 2: Install Erlang and RabbitMQ**
|
||||
|
||||
Run the following on **all nodes**:
|
||||
|
||||
### **1. Add the RabbitMQ Repository**
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install -y curl gnupg
|
||||
curl -fsSL https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey | sudo tee /usr/share/keyrings/rabbitmq-key.asc
|
||||
echo "deb [signed-by=/usr/share/keyrings/rabbitmq-key.asc] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list
|
||||
```
|
||||
|
||||
### **2. Install Erlang and RabbitMQ**
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install -y rabbitmq-server
|
||||
```
|
||||
|
||||
### **3. Enable RabbitMQ**
|
||||
|
||||
```bash
|
||||
sudo systemctl enable --now rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 3: Configure Clustering**
|
||||
|
||||
### **1. Stop RabbitMQ on All Nodes**
|
||||
|
||||
```bash
|
||||
sudo systemctl stop rabbitmq-server
|
||||
```
|
||||
|
||||
### **2. Configure Cookie for Clustering**
|
||||
|
||||
Run on **all nodes** (same cookie ensures clustering works):
|
||||
|
||||
```bash
|
||||
echo "MY_CLUSTER_COOKIE" | sudo tee /var/lib/rabbitmq/.erlang.cookie
|
||||
sudo chmod 600 /var/lib/rabbitmq/.erlang.cookie
|
||||
```
|
||||
|
||||
Replace `"MY_CLUSTER_COOKIE"` with a strong, identical value on all nodes.
|
||||
|
||||
---
|
||||
|
||||
## **Step 4: Join Nodes to the Cluster**
|
||||
|
||||
Perform this on **nodes 2 and 3**, joining them to **node1**:
|
||||
|
||||
```bash
|
||||
sudo rabbitmqctl stop_app
|
||||
sudo rabbitmqctl join_cluster rabbit@rabbitmq-node1
|
||||
sudo rabbitmqctl start_app
|
||||
```
|
||||
|
||||
Check cluster status:
|
||||
|
||||
```bash
|
||||
sudo rabbitmqctl cluster_status
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 5: Enable High Availability (HA) Mirroring**
|
||||
|
||||
To replicate all queues, run on **any one node**:
|
||||
|
||||
```bash
|
||||
rabbitmqctl set_policy ha-all "^.*" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
|
||||
```
|
||||
|
||||
This ensures all queues are **replicated across all nodes**.
|
||||
|
||||
---
|
||||
|
||||
## **Step 6: Enable Management UI**
|
||||
|
||||
Run on **each node** to enable the web interface:
|
||||
|
||||
```bash
|
||||
sudo rabbitmq-plugins enable rabbitmq_management
|
||||
```
|
||||
|
||||
Access at:
|
||||
**http://[NODE_IP]:15672**
|
||||
(Default login: `guest/guest`, change this for security.)
|
||||
|
||||
---
|
||||
|
||||
## **Step 7: Test the Cluster**
|
||||
|
||||
Run on **each node**:
|
||||
|
||||
```bash
|
||||
rabbitmqctl list_queues
|
||||
```
|
||||
|
||||
Queues should be visible and synchronized.
|
||||
|
||||
---
|
||||
|
||||
## **Step 8: Enable Auto-Recovery** (Optional)
|
||||
|
||||
Edit `/etc/rabbitmq/rabbitmq.conf` on **each node** and add:
|
||||
|
||||
```ini
|
||||
cluster_formation.peer_discovery_backend = classic_config
|
||||
cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-node1
|
||||
cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-node2
|
||||
cluster_formation.classic_config.nodes.3 = rabbit@rabbitmq-node3
|
||||
```
|
||||
|
||||
Then restart RabbitMQ:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 9: Secure the Cluster** (Recommended)
|
||||
|
||||
### **1. Create an Admin User**
|
||||
|
||||
```bash
|
||||
rabbitmqctl add_user admin StrongPassword123!
|
||||
rabbitmqctl set_user_tags admin administrator
|
||||
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
|
||||
```
|
||||
|
||||
Then **disable the guest account**:
|
||||
|
||||
```bash
|
||||
rabbitmqctl delete_user guest
|
||||
```
|
||||
|
||||
### **2. Enable TLS (Optional)**
|
||||
|
||||
For security, configure TLS in `/etc/rabbitmq/rabbitmq.conf`. Refer to RabbitMQ’s [TLS guide](https://www.rabbitmq.com/ssl.html).
|
||||
|
||||
---
|
||||
|
||||
## **Step 10: Setup Monitoring (Optional)**
|
||||
|
||||
Install **Prometheus & Grafana** or use **RabbitMQ Prometheus plugin**:
|
||||
|
||||
```bash
|
||||
sudo rabbitmq-plugins enable rabbitmq_prometheus
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Now your RabbitMQ cluster is fully set up with **replication and high availability**! 🚀
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Instructions to fix **unexpected** configuration errors
|
||||
|
||||
If you can't find the RabbitMQ config file under `/etc/rabbitmq`, it may not exist by default. You need to **create it manually**. Here's how:
|
||||
|
||||
## **1️⃣ Create the Configuration File**
|
||||
|
||||
RabbitMQ uses either a **`.conf` file** (modern format) or a **`.config` file** (legacy format). The recommended format is `.conf`.
|
||||
|
||||
Create the file if it doesn't exist:
|
||||
|
||||
```bash
|
||||
sudo nano /etc/rabbitmq/rabbitmq.conf
|
||||
```
|
||||
|
||||
Then add the following cluster configuration:
|
||||
|
||||
```
|
||||
cluster_formation.peer_discovery_backend = classic_config
|
||||
cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-main
|
||||
cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-replica
|
||||
```
|
||||
|
||||
Save and exit (`CTRL+X`, then `Y`, then `Enter`).
|
||||
|
||||
---
|
||||
|
||||
## **2️⃣ Set Correct Permissions**
|
||||
|
||||
Ensure the RabbitMQ user can read it:
|
||||
|
||||
```bash
|
||||
sudo chown rabbitmq:rabbitmq /etc/rabbitmq/rabbitmq.conf
|
||||
sudo chmod 644 /etc/rabbitmq/rabbitmq.conf
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **3️⃣ Restart RabbitMQ**
|
||||
|
||||
After modifying the configuration, restart the RabbitMQ service:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart rabbitmq-server
|
||||
```
|
||||
|
||||
Check the status:
|
||||
|
||||
```bash
|
||||
sudo systemctl status rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **4️⃣ Verify the Cluster Configuration**
|
||||
|
||||
After restarting, verify that clustering is working:
|
||||
|
||||
```bash
|
||||
rabbitmqctl cluster_status
|
||||
```
|
||||
|
||||
If the nodes are listed correctly, your setup is working.
|
||||
|
||||
---
|
||||
|
||||
## **5️⃣ If Using the Legacy `.config` Format**
|
||||
|
||||
Some older installations use an **Erlang-based configuration file** (`rabbitmq.config`). If you prefer that, create:
|
||||
|
||||
```bash
|
||||
sudo nano /etc/rabbitmq/rabbitmq.config
|
||||
```
|
||||
|
||||
Add this:
|
||||
|
||||
```erlang
|
||||
[
|
||||
{rabbit, [
|
||||
{cluster_formation, [
|
||||
{peer_discovery_backend, classic_config},
|
||||
{classic_config, [
|
||||
{nodes, ['rabbit@rabbitmq-main', 'rabbit@rabbitmq-replica']}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
].
|
||||
```
|
||||
|
||||
Then restart RabbitMQ:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### **🔍 Troubleshooting**
|
||||
|
||||
❌ **RabbitMQ doesn't restart?**
|
||||
Check logs for errors:
|
||||
|
||||
```bash
|
||||
sudo journalctl -u rabbitmq-server --no-pager | tail -50
|
||||
```
|
||||
|
||||
❌ **Cluster not forming?**
|
||||
Try forcing a node to join manually:
|
||||
|
||||
```bash
|
||||
rabbitmqctl stop_app
|
||||
rabbitmqctl join_cluster rabbit@rabbitmq-main
|
||||
rabbitmqctl start_app
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Instructions to fix **unexpected** management UI authentication errors
|
||||
|
||||
stackoverflow answer [link](https://stackoverflow.com/a/40845332/27251837)
|
||||
|
||||
## Answer
|
||||
|
||||
### ❌ **Cannot login with guest/guest credentials**
|
||||
|
||||
I had the same Problem..
|
||||
|
||||
I installed RabbitMQ and Enabled Web Interface also but still couldn't sign in with any user i newly created, this is because you need to be administrator to access this.
|
||||
|
||||
Do not create any config file and mess with it..
|
||||
|
||||
This is what i did then,
|
||||
|
||||
1. Add a new/fresh user, say user test and password test:
|
||||
|
||||
```bash
|
||||
rabbitmqctl add_user test test
|
||||
```
|
||||
|
||||
2. Give administrative access to the new user:
|
||||
|
||||
```bash
|
||||
rabbitmqctl set_user_tags test administrator
|
||||
```
|
||||
|
||||
3. Set permission to newly created user:
|
||||
|
||||
```bash
|
||||
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
|
||||
```
|
||||
|
||||
That's it, enjoy :)
|
||||
Here’s a step-by-step guide to setting up a **RabbitMQ cluster with replication** correctly:
|
||||
|
||||
---
|
||||
|
||||
## **Step 1: Prepare the Servers**
|
||||
|
||||
Ensure you have at least **three** nodes (recommended for HA) with:
|
||||
|
||||
- Ubuntu 22.04 (or a supported OS)
|
||||
- Sufficient CPU/RAM based on workload
|
||||
- Open necessary firewall ports (**5672, 15672, 25672**)
|
||||
|
||||
Set hostnames for clarity:
|
||||
|
||||
```bash
|
||||
sudo hostnamectl set-hostname rabbitmq-node1 # Change for each node
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 2: Install Erlang and RabbitMQ**
|
||||
|
||||
Run the following on **all nodes**:
|
||||
|
||||
### **1. Add the RabbitMQ Repository**
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install -y curl gnupg
|
||||
curl -fsSL https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey | sudo tee /usr/share/keyrings/rabbitmq-key.asc
|
||||
echo "deb [signed-by=/usr/share/keyrings/rabbitmq-key.asc] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list
|
||||
```
|
||||
|
||||
### **2. Install Erlang and RabbitMQ**
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install -y rabbitmq-server
|
||||
```
|
||||
|
||||
### **3. Enable RabbitMQ**
|
||||
|
||||
```bash
|
||||
sudo systemctl enable --now rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 3: Configure Clustering**
|
||||
|
||||
### **1. Stop RabbitMQ on All Nodes**
|
||||
|
||||
```bash
|
||||
sudo systemctl stop rabbitmq-server
|
||||
```
|
||||
|
||||
### **2. Configure Cookie for Clustering**
|
||||
|
||||
Run on **all nodes** (same cookie ensures clustering works):
|
||||
|
||||
```bash
|
||||
echo "MY_CLUSTER_COOKIE" | sudo tee /var/lib/rabbitmq/.erlang.cookie
|
||||
sudo chmod 600 /var/lib/rabbitmq/.erlang.cookie
|
||||
```
|
||||
|
||||
Replace `"MY_CLUSTER_COOKIE"` with a strong, identical value on all nodes.
|
||||
|
||||
---
|
||||
|
||||
## **Step 4: Join Nodes to the Cluster**
|
||||
|
||||
Perform this on **nodes 2 and 3**, joining them to **node1**:
|
||||
|
||||
```bash
|
||||
sudo rabbitmqctl stop_app
|
||||
sudo rabbitmqctl join_cluster rabbit@rabbitmq-node1
|
||||
sudo rabbitmqctl start_app
|
||||
```
|
||||
|
||||
Check cluster status:
|
||||
|
||||
```bash
|
||||
sudo rabbitmqctl cluster_status
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 5: Enable High Availability (HA) Mirroring**
|
||||
|
||||
To replicate all queues, run on **any one node**:
|
||||
|
||||
```bash
|
||||
rabbitmqctl set_policy ha-all "^.*" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
|
||||
```
|
||||
|
||||
This ensures all queues are **replicated across all nodes**.
|
||||
|
||||
---
|
||||
|
||||
## **Step 6: Enable Management UI**
|
||||
|
||||
Run on **each node** to enable the web interface:
|
||||
|
||||
```bash
|
||||
sudo rabbitmq-plugins enable rabbitmq_management
|
||||
```
|
||||
|
||||
Access at:
|
||||
**http://[NODE_IP]:15672**
|
||||
(Default login: `guest/guest`, change this for security.)
|
||||
|
||||
---
|
||||
|
||||
## **Step 7: Test the Cluster**
|
||||
|
||||
Run on **each node**:
|
||||
|
||||
```bash
|
||||
rabbitmqctl list_queues
|
||||
```
|
||||
|
||||
Queues should be visible and synchronized.
|
||||
|
||||
---
|
||||
|
||||
## **Step 8: Enable Auto-Recovery** (Optional)
|
||||
|
||||
Edit `/etc/rabbitmq/rabbitmq.conf` on **each node** and add:
|
||||
|
||||
```ini
|
||||
cluster_formation.peer_discovery_backend = classic_config
|
||||
cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-node1
|
||||
cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-node2
|
||||
cluster_formation.classic_config.nodes.3 = rabbit@rabbitmq-node3
|
||||
```
|
||||
|
||||
Then restart RabbitMQ:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 9: Secure the Cluster** (Recommended)
|
||||
|
||||
### **1. Create an Admin User**
|
||||
|
||||
```bash
|
||||
rabbitmqctl add_user admin StrongPassword123!
|
||||
rabbitmqctl set_user_tags admin administrator
|
||||
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
|
||||
```
|
||||
|
||||
Then **disable the guest account**:
|
||||
|
||||
```bash
|
||||
rabbitmqctl delete_user guest
|
||||
```
|
||||
|
||||
### **2. Enable TLS (Optional)**
|
||||
|
||||
For security, configure TLS in `/etc/rabbitmq/rabbitmq.conf`. Refer to RabbitMQ’s [TLS guide](https://www.rabbitmq.com/ssl.html).
|
||||
|
||||
---
|
||||
|
||||
## **Step 10: Setup Monitoring (Optional)**
|
||||
|
||||
Install **Prometheus & Grafana** or use **RabbitMQ Prometheus plugin**:
|
||||
|
||||
```bash
|
||||
sudo rabbitmq-plugins enable rabbitmq_prometheus
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Now your RabbitMQ cluster is fully set up with **replication and high availability**! 🚀
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Instructions to fix **unexpected** configuration errors
|
||||
|
||||
If you can't find the RabbitMQ config file under `/etc/rabbitmq`, it may not exist by default. You need to **create it manually**. Here's how:
|
||||
|
||||
## **1️⃣ Create the Configuration File**
|
||||
|
||||
RabbitMQ uses either a **`.conf` file** (modern format) or a **`.config` file** (legacy format). The recommended format is `.conf`.
|
||||
|
||||
Create the file if it doesn't exist:
|
||||
|
||||
```bash
|
||||
sudo nano /etc/rabbitmq/rabbitmq.conf
|
||||
```
|
||||
|
||||
Then add the following cluster configuration:
|
||||
|
||||
```
|
||||
cluster_formation.peer_discovery_backend = classic_config
|
||||
cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-main
|
||||
cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-replica
|
||||
```
|
||||
|
||||
Save and exit (`CTRL+X`, then `Y`, then `Enter`).
|
||||
|
||||
---
|
||||
|
||||
## **2️⃣ Set Correct Permissions**
|
||||
|
||||
Ensure the RabbitMQ user can read it:
|
||||
|
||||
```bash
|
||||
sudo chown rabbitmq:rabbitmq /etc/rabbitmq/rabbitmq.conf
|
||||
sudo chmod 644 /etc/rabbitmq/rabbitmq.conf
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **3️⃣ Restart RabbitMQ**
|
||||
|
||||
After modifying the configuration, restart the RabbitMQ service:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart rabbitmq-server
|
||||
```
|
||||
|
||||
Check the status:
|
||||
|
||||
```bash
|
||||
sudo systemctl status rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **4️⃣ Verify the Cluster Configuration**
|
||||
|
||||
After restarting, verify that clustering is working:
|
||||
|
||||
```bash
|
||||
rabbitmqctl cluster_status
|
||||
```
|
||||
|
||||
If the nodes are listed correctly, your setup is working.
|
||||
|
||||
---
|
||||
|
||||
## **5️⃣ If Using the Legacy `.config` Format**
|
||||
|
||||
Some older installations use an **Erlang-based configuration file** (`rabbitmq.config`). If you prefer that, create:
|
||||
|
||||
```bash
|
||||
sudo nano /etc/rabbitmq/rabbitmq.config
|
||||
```
|
||||
|
||||
Add this:
|
||||
|
||||
```erlang
|
||||
[
|
||||
{rabbit, [
|
||||
{cluster_formation, [
|
||||
{peer_discovery_backend, classic_config},
|
||||
{classic_config, [
|
||||
{nodes, ['rabbit@rabbitmq-main', 'rabbit@rabbitmq-replica']}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
].
|
||||
```
|
||||
|
||||
Then restart RabbitMQ:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart rabbitmq-server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### **🔍 Troubleshooting**
|
||||
|
||||
❌ **RabbitMQ doesn't restart?**
|
||||
Check logs for errors:
|
||||
|
||||
```bash
|
||||
sudo journalctl -u rabbitmq-server --no-pager | tail -50
|
||||
```
|
||||
|
||||
❌ **Cluster not forming?**
|
||||
Try forcing a node to join manually:
|
||||
|
||||
```bash
|
||||
rabbitmqctl stop_app
|
||||
rabbitmqctl join_cluster rabbit@rabbitmq-main
|
||||
rabbitmqctl start_app
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# Instructions to fix **unexpected** management UI authentication errors
|
||||
|
||||
stackoverflow answer [link](https://stackoverflow.com/a/40845332/27251837)
|
||||
|
||||
## Answer
|
||||
|
||||
### ❌ **Cannot login with guest/guest credentials**
|
||||
|
||||
I had the same Problem..
|
||||
|
||||
I installed RabbitMQ and Enabled Web Interface also but still couldn't sign in with any user i newly created, this is because you need to be administrator to access this.
|
||||
|
||||
Do not create any config file and mess with it..
|
||||
|
||||
This is what i did then,
|
||||
|
||||
1. Add a new/fresh user, say user test and password test:
|
||||
|
||||
```bash
|
||||
rabbitmqctl add_user test test
|
||||
```
|
||||
|
||||
2. Give administrative access to the new user:
|
||||
|
||||
```bash
|
||||
rabbitmqctl set_user_tags test administrator
|
||||
```
|
||||
|
||||
3. Set permission to newly created user:
|
||||
|
||||
```bash
|
||||
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
|
||||
```
|
||||
|
||||
That's it, enjoy :)
|
||||
@ -1,138 +1,139 @@
|
||||
# 📌 Установка Gotify в Docker на Ubuntu 24.04
|
||||
|
||||
## 1. Установка Docker и Docker Compose
|
||||
Если Docker не установлен, установим его:
|
||||
```sh
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
sudo apt install -y docker.io docker-compose
|
||||
sudo systemctl enable --now docker
|
||||
```
|
||||
Проверим версию:
|
||||
```sh
|
||||
docker --version
|
||||
docker-compose --version
|
||||
```
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
## 2. Создание директории для Gotify
|
||||
Лучшее место для сторонних сервисов — `/opt`:
|
||||
```sh
|
||||
sudo mkdir -p /opt/gotify
|
||||
cd /opt/gotify
|
||||
```
|
||||
|
||||
## 3. Создаём самоподписанный сертификат
|
||||
```sh
|
||||
sudo mkdir -p /opt/gotify/certs && cd /opt/gotify/certs
|
||||
openssl req -x509 -newkey rsa:4096 -keyout gotify.key -out gotify.crt -days 365 -nodes -subj "/CN=your.domain.com"
|
||||
```
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
## 3. Создание `docker-compose.yml`
|
||||
Создадим конфигурацию:
|
||||
```sh
|
||||
sudo mcedit /opt/gotify/docker-compose.yml
|
||||
```
|
||||
Добавляем:
|
||||
```yaml
|
||||
services:
|
||||
gotify:
|
||||
image: gotify/server
|
||||
container_name: gotify
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- "./certs:/certs"
|
||||
- "./data:/app/data"
|
||||
ports:
|
||||
- "8080:443" # HTTPS
|
||||
environment:
|
||||
- GOTIFY_DEFAULTUSER_NAME=admin
|
||||
- GOTIFY_DEFAULTUSER_PASS=s23uBXreliGIAVOohXhW
|
||||
- TZ=Asia/Almaty
|
||||
- GOTIFY_SERVER_SSL_ENABLED=true
|
||||
- GOTIFY_SERVER_SSL_CERTFILE=/certs/gotify.crt
|
||||
- GOTIFY_SERVER_SSL_CERTKEY=/certs/gotify.key
|
||||
networks:
|
||||
- gotify-net
|
||||
|
||||
networks:
|
||||
gotify-net:
|
||||
driver: bridge
|
||||
```
|
||||
💡 **Что здесь важно?**
|
||||
- **`security_opt: - no-new-privileges:true`** → запрещает повышать привилегии в контейнере.
|
||||
- **`volumes: ./data:/app/data`** → сохраняет данные вне контейнера.
|
||||
- **`restart: unless-stopped`** → перезапускает Gotify, если он внезапно упадёт.
|
||||
- **`ports: - "8080:80"`** → Gotify будет доступен на порту `8080`.
|
||||
|
||||
🔑 **Замените пароль** (`supersecretpassword`) на свой!
|
||||
|
||||
---
|
||||
|
||||
## 4. Запуск Gotify
|
||||
Запускаем контейнер:
|
||||
```sh
|
||||
cd /opt/gotify
|
||||
sudo docker compose down
|
||||
sudo docker-compose up -d
|
||||
```
|
||||
Проверяем статус:
|
||||
```sh
|
||||
sudo docker ps
|
||||
```
|
||||
Вы должны увидеть работающий контейнер `gotify`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Проверка работы
|
||||
Открываем браузер и переходим:
|
||||
👉 **https://192.168.200.84:8080**
|
||||
👉 **https://gotify.locust.kz:8443**
|
||||
|
||||
Логинимся:
|
||||
- **Имя**: `admin`
|
||||
- **Пароль**: тот, что указан в `GOTIFY_DEFAULTUSER_PASS`
|
||||
|
||||
---
|
||||
|
||||
## 6. Автоматический запуск при загрузке
|
||||
Docker уже настроен на автозапуск, но проверим:
|
||||
```sh
|
||||
sudo systemctl enable --now docker
|
||||
```
|
||||
Чтобы Gotify запускался автоматически:
|
||||
```sh
|
||||
cd /opt/gotify
|
||||
sudo docker-compose restart
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. Логи и управление
|
||||
Просмотр логов:
|
||||
```sh
|
||||
sudo docker-compose logs -f
|
||||
```
|
||||
Перезапуск контейнера:
|
||||
```sh
|
||||
sudo docker-compose restart
|
||||
```
|
||||
Остановка:
|
||||
```sh
|
||||
sudo docker-compose down
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Удаление Gotify (если потребуется)
|
||||
```sh
|
||||
cd /opt/gotify
|
||||
sudo docker-compose down
|
||||
sudo rm -rf /opt/gotify
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ Готово!
|
||||
Теперь Gotify работает на порту `80` с безопасными настройками (`no-new-privileges:true`). 🚀
|
||||
# 📌 Установка Gotify в Docker на Ubuntu 24.04
|
||||
|
||||
## 1. Установка Docker и Docker Compose
|
||||
Если Docker не установлен, установим его:
|
||||
```sh
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
sudo apt install -y docker.io docker-compose
|
||||
sudo systemctl enable --now docker
|
||||
```
|
||||
Проверим версию:
|
||||
```sh
|
||||
docker --version
|
||||
docker-compose --version
|
||||
```
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
## 2. Создание директории для Gotify
|
||||
Лучшее место для сторонних сервисов — `/opt`:
|
||||
```sh
|
||||
sudo mkdir -p /opt/gotify
|
||||
cd /opt/gotify
|
||||
```
|
||||
|
||||
## 3. Создаём самоподписанный сертификат
|
||||
```sh
|
||||
sudo mkdir -p /opt/gotify/certs && cd /opt/gotify/certs
|
||||
openssl req -x509 -newkey rsa:4096 -keyout gotify.key -out gotify.crt -days 365 -nodes -subj "/CN=your.domain.com"
|
||||
```
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
## 3. Создание `docker-compose.yml`
|
||||
Создадим конфигурацию:
|
||||
```sh
|
||||
sudo mcedit /opt/gotify/docker-compose.yml
|
||||
```
|
||||
Добавляем:
|
||||
```yaml
|
||||
services:
|
||||
gotify:
|
||||
image: gotify/server
|
||||
container_name: gotify
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- "./certs:/certs"
|
||||
- "./data:/app/data"
|
||||
ports:
|
||||
- "8080:443" # HTTPS
|
||||
environment:
|
||||
- GOTIFY_DEFAULTUSER_NAME=admin
|
||||
- GOTIFY_DEFAULTUSER_PASS=s23uBXreliGIAVOohXhW
|
||||
- TZ=Asia/Almaty
|
||||
- GOTIFY_SERVER_SSL_ENABLED=true
|
||||
- GOTIFY_SERVER_SSL_CERTFILE=/certs/gotify.crt
|
||||
- GOTIFY_SERVER_SSL_CERTKEY=/certs/gotify.key
|
||||
- GIN_MODE=debug
|
||||
networks:
|
||||
- gotify-net
|
||||
|
||||
networks:
|
||||
gotify-net:
|
||||
driver: bridge
|
||||
```
|
||||
💡 **Что здесь важно?**
|
||||
- **`security_opt: - no-new-privileges:true`** → запрещает повышать привилегии в контейнере.
|
||||
- **`volumes: ./data:/app/data`** → сохраняет данные вне контейнера.
|
||||
- **`restart: unless-stopped`** → перезапускает Gotify, если он внезапно упадёт.
|
||||
- **`ports: - "8080:80"`** → Gotify будет доступен на порту `8080`.
|
||||
|
||||
🔑 **Замените пароль** (`supersecretpassword`) на свой!
|
||||
|
||||
---
|
||||
|
||||
## 4. Запуск Gotify
|
||||
Запускаем контейнер:
|
||||
```sh
|
||||
cd /opt/gotify
|
||||
sudo docker compose down
|
||||
sudo docker-compose up -d
|
||||
```
|
||||
Проверяем статус:
|
||||
```sh
|
||||
sudo docker ps
|
||||
```
|
||||
Вы должны увидеть работающий контейнер `gotify`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Проверка работы
|
||||
Открываем браузер и переходим:
|
||||
👉 **https://192.168.200.84:8080**
|
||||
👉 **https://gotify.locust.kz:8443**
|
||||
|
||||
Логинимся:
|
||||
- **Имя**: `admin`
|
||||
- **Пароль**: тот, что указан в `GOTIFY_DEFAULTUSER_PASS`
|
||||
|
||||
---
|
||||
|
||||
## 6. Автоматический запуск при загрузке
|
||||
Docker уже настроен на автозапуск, но проверим:
|
||||
```sh
|
||||
sudo systemctl enable --now docker
|
||||
```
|
||||
Чтобы Gotify запускался автоматически:
|
||||
```sh
|
||||
cd /opt/gotify
|
||||
sudo docker-compose restart
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. Логи и управление
|
||||
Просмотр логов:
|
||||
```sh
|
||||
sudo docker-compose logs -f
|
||||
```
|
||||
Перезапуск контейнера:
|
||||
```sh
|
||||
sudo docker-compose restart
|
||||
```
|
||||
Остановка:
|
||||
```sh
|
||||
sudo docker-compose down
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Удаление Gotify (если потребуется)
|
||||
```sh
|
||||
cd /opt/gotify
|
||||
sudo docker-compose down
|
||||
sudo rm -rf /opt/gotify
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ Готово!
|
||||
Теперь Gotify работает на порту `80` с безопасными настройками (`no-new-privileges:true`). 🚀
|
||||
@ -1,38 +1,38 @@
|
||||
Открываю нужный сервер
|
||||
```sh
|
||||
wsl
|
||||
```
|
||||
|
||||
```sh
|
||||
curl -sSX POST https://istt-kz.zulipchat.com/api/v1/fetch_api_key \
|
||||
--data-urlencode username=ivanov.i@istt.kz \
|
||||
--data-urlencode password=fsUHb3hf3QCdpBLsKyhL
|
||||
```
|
||||
Выдало:
|
||||
```json
|
||||
{
|
||||
"result":"success",
|
||||
"msg":"",
|
||||
"api_key":"91kQqr13HCwFP2HeARWPHxrfksYPH82p",
|
||||
"email":"ivanov.i@istt.kz",
|
||||
"user_id":880555
|
||||
}
|
||||
```
|
||||
|
||||
```sh
|
||||
curl -X POST https://istt-kz.zulipchat.com/api/v1/messages \
|
||||
-u "ivanov.i@istt.kz:91kQqr13HCwFP2HeARWPHxrfksYPH82p" \
|
||||
-d "type=stream" \
|
||||
-d "to=general" \
|
||||
-d "topic=Тест5" \
|
||||
-d "content=Привет из консоли!"
|
||||
```
|
||||
|
||||
```sh
|
||||
curl -X POST https://istt-kz.zulipchat.com/api/v1/messages \
|
||||
-u "ivanov.i@istt.kz:91kQqr13HCwFP2HeARWPHxrfksYPH82p" \
|
||||
-d "type=private" \
|
||||
-d "to=ivanov.i@istt.kz" \
|
||||
-d "topic=Тест5" \
|
||||
-d "content=Привет из консоли!"
|
||||
```
|
||||
Открываю нужный сервер
|
||||
```sh
|
||||
wsl
|
||||
```
|
||||
|
||||
```sh
|
||||
curl -sSX POST https://istt-kz.zulipchat.com/api/v1/fetch_api_key \
|
||||
--data-urlencode username=ivanov.i@istt.kz \
|
||||
--data-urlencode password=fsUHb3hf3QCdpBLsKyhL
|
||||
```
|
||||
Выдало:
|
||||
```json
|
||||
{
|
||||
"result":"success",
|
||||
"msg":"",
|
||||
"api_key":"91kQqr13HCwFP2HeARWPHxrfksYPH82p",
|
||||
"email":"ivanov.i@istt.kz",
|
||||
"user_id":880555
|
||||
}
|
||||
```
|
||||
|
||||
```sh
|
||||
curl -X POST https://istt-kz.zulipchat.com/api/v1/messages \
|
||||
-u "ivanov.i@istt.kz:91kQqr13HCwFP2HeARWPHxrfksYPH82p" \
|
||||
-d "type=stream" \
|
||||
-d "to=general" \
|
||||
-d "topic=Тест5" \
|
||||
-d "content=Привет из консоли!"
|
||||
```
|
||||
|
||||
```sh
|
||||
curl -X POST https://istt-kz.zulipchat.com/api/v1/messages \
|
||||
-u "ivanov.i@istt.kz:91kQqr13HCwFP2HeARWPHxrfksYPH82p" \
|
||||
-d "type=private" \
|
||||
-d "to=ivanov.i@istt.kz" \
|
||||
-d "topic=Тест5" \
|
||||
-d "content=Привет из консоли!"
|
||||
```
|
||||
@ -206,7 +206,8 @@ sudo pdnsutil add-record locust.ge @ NS 3600 ns2.geovizor.top
|
||||
|
||||
For deleting record please run command:
|
||||
```sh
|
||||
pdnsutil delete-rrset locust.ge locust.ge.locust.ge NS
|
||||
sudo pdnsutil delete-rrset locust.ge locust.ge.locust.ge NS
|
||||
sudo pdnsutil delete-rrset geovizor.top gotify A
|
||||
```
|
||||
|
||||
|
||||
@ -223,7 +224,7 @@ Minimum = 3600 (1 час)
|
||||
Проверим список зон
|
||||
```sh
|
||||
sudo pdnsutil list-all-zones &&
|
||||
sudo pdnsutil list-zone locust.kz
|
||||
sudo pdnsutil list-zone geovizor.top
|
||||
```
|
||||
Проверяем отвечалет ли:
|
||||
```sh
|
||||
@ -364,7 +365,7 @@ journalctl -u pdns-recursor --no-pager | tail -n 50
|
||||
```
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
## ********** По идее отключать не нужно так как systemd-resolved использует другой IP: 127.0.0.54:53 (Отключаю systemd-resolved иначе он будет конфликтовать с PowerDNS) **********
|
||||
## ********** По идее systemd-resolved отключать не нужно так как он использует другой IP: 127.0.0.54:53 **********
|
||||
|
||||
Редактирую /etc/netplan/ для того чтобы прописать поднятый DNS сервер на 127.0.0.1 (не знаю сработает ли так как отключу systemd-resolved)
|
||||
```sh
|
||||
@ -613,7 +614,7 @@ open http://192.168.200.85:9191/login
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
Настраиваем запус на постоянную работу через Gunicorn и systemd
|
||||
Настраиваем запуск на постоянную работу через Gunicorn и systemd
|
||||
|
||||
```sh
|
||||
cd /opt/web/powerdns-admin &&
|
||||
|
||||
52
DNS/Ubuntu_config.md
Normal file
52
DNS/Ubuntu_config.md
Normal file
@ -0,0 +1,52 @@
|
||||
Чтобы в Ubuntu все домены с маской *.local отправлялись на DNS-сервер 192.168.200.85 (где работает PowerDNS на порту 53), тебе нужно настроить DNS-резолвинг так, чтобы:
|
||||
|
||||
Все запросы к доменам, оканчивающимся на .local, отправлялись на указанный DNS.
|
||||
|
||||
Остальные домены резолвились через системный DNS как обычно.
|
||||
|
||||
✅ Способ 1: Использовать systemd-resolved (рекомендуется для Ubuntu 18.04+, особенно 20.04 и 22.04)
|
||||
Ubuntu по умолчанию использует systemd-resolved, который поддерживает пер-доменное направление DNS-запросов.
|
||||
|
||||
Шаги:
|
||||
Создай файл в /etc/systemd/resolved.conf.d/:
|
||||
```sh
|
||||
ssh igor@192.168.200.84 -p 22
|
||||
```
|
||||
|
||||
Создаю директорию
|
||||
```sh
|
||||
sudo mkdir -p /etc/systemd/resolved.conf.d &&
|
||||
sudo mcedit /etc/systemd/resolved.conf.d/local-dns.conf
|
||||
```
|
||||
|
||||
Прописываю содержимое:
|
||||
```conf
|
||||
[Resolve]
|
||||
DNS=192.168.200.85
|
||||
Domains=~local
|
||||
```
|
||||
|
||||
Перезапускаю
|
||||
```sh
|
||||
sudo systemctl restart systemd-resolved &&
|
||||
```
|
||||
|
||||
Проверяю настройки
|
||||
```sh
|
||||
resolvectl status
|
||||
```
|
||||
|
||||
Проверяем
|
||||
```sh
|
||||
ping gotify.local
|
||||
```
|
||||
Проверяем сертификат:
|
||||
```sh
|
||||
curl https://gotify.local
|
||||
```
|
||||
|
||||
Добавляем корневой сертификат для домена local.
|
||||
```sh
|
||||
sudo cp rootCA.crt /usr/local/share/ca-certificates/rootCA.crt &&
|
||||
sudo update-ca-certificates
|
||||
```
|
||||
@ -1,94 +1,94 @@
|
||||
```sh
|
||||
sudo apt update &&
|
||||
sudo apt install unbound -y &&
|
||||
unbound -V
|
||||
```
|
||||
|
||||
```sh
|
||||
sudo systemctl start unbound &&
|
||||
sudo systemctl enable unbound &&
|
||||
sudo systemctl status unbound
|
||||
```
|
||||
On Windows configuration is:
|
||||
|
||||
```yaml
|
||||
server:
|
||||
verbosity: 4
|
||||
qname-minimisation: no
|
||||
interface: 127.0.0.1
|
||||
do-ip6: no
|
||||
do-ip4: yes
|
||||
logfile: "C:\unbound.log"
|
||||
domain-insecure: "test."
|
||||
domain-insecure: "local."
|
||||
domain-insecure: "pizza."
|
||||
auto-trust-anchor-file: "C:\Program Files\Unbound\root.key"
|
||||
private-address: ::/0
|
||||
harden-dnssec-stripped: no
|
||||
harden-referral-path: no
|
||||
|
||||
# Явно указываем, что зона "test." не локальная
|
||||
local-zone: "test." transparent
|
||||
|
||||
forward-zone:
|
||||
name: "test."
|
||||
forward-addr: 192.168.200.85@5300
|
||||
|
||||
forward-zone:
|
||||
name: "local."
|
||||
forward-addr: 192.168.200.85@5300
|
||||
|
||||
forward-zone:
|
||||
name: "pizza."
|
||||
forward-addr: 10.101.1.31@53
|
||||
|
||||
forward-zone:
|
||||
name: "srv."
|
||||
forward-addr: 10.101.1.31@53
|
||||
|
||||
remote-control:
|
||||
control-enable: yes
|
||||
control-interface: 127.0.0.1
|
||||
control-use-cert: no
|
||||
```
|
||||
|
||||
On Linux conf file devide on anoter files
|
||||
```sh
|
||||
sudo mcedit /etc/unbound/unbound.conf
|
||||
```
|
||||
|
||||
```sh
|
||||
cd /etc/unbound/ &&
|
||||
sudo mc
|
||||
```
|
||||
|
||||
Получить полный список локальных зон можно так: unbound-control
|
||||
```sh
|
||||
unbound-control list_local_zones
|
||||
```
|
||||
|
||||
```sh
|
||||
sudo systemctl restart unbound
|
||||
```
|
||||
|
||||
```sh
|
||||
sudo systemctl status unbound.service
|
||||
```
|
||||
```sh
|
||||
sudo journalctl -xeu unbound.service
|
||||
```
|
||||
|
||||
Check on errors:
|
||||
```sh
|
||||
sudo unbound-checkconf /etc/unbound/unbound.conf
|
||||
```
|
||||
|
||||
|
||||
Прописываем для определенного интерфейса:
|
||||
```sh
|
||||
sudo resolvectl dns wlp14s0 127.0.0.1
|
||||
```
|
||||
Проверяем что стоит в качестве NDS резольвера
|
||||
```sh
|
||||
resolvectl status
|
||||
```
|
||||
```sh
|
||||
sudo apt update &&
|
||||
sudo apt install unbound -y &&
|
||||
unbound -V
|
||||
```
|
||||
|
||||
```sh
|
||||
sudo systemctl start unbound &&
|
||||
sudo systemctl enable unbound &&
|
||||
sudo systemctl status unbound
|
||||
```
|
||||
On Windows configuration is:
|
||||
|
||||
```yaml
|
||||
server:
|
||||
verbosity: 4
|
||||
qname-minimisation: no
|
||||
interface: 127.0.0.1
|
||||
do-ip6: no
|
||||
do-ip4: yes
|
||||
logfile: "C:\unbound.log"
|
||||
domain-insecure: "test."
|
||||
domain-insecure: "local."
|
||||
domain-insecure: "pizza."
|
||||
auto-trust-anchor-file: "C:\Program Files\Unbound\root.key"
|
||||
private-address: ::/0
|
||||
harden-dnssec-stripped: no
|
||||
harden-referral-path: no
|
||||
|
||||
# Явно указываем, что зона "test." не локальная
|
||||
local-zone: "test." transparent
|
||||
|
||||
forward-zone:
|
||||
name: "test."
|
||||
forward-addr: 192.168.200.85@5300
|
||||
|
||||
forward-zone:
|
||||
name: "local."
|
||||
forward-addr: 192.168.200.85@5300
|
||||
|
||||
forward-zone:
|
||||
name: "pizza."
|
||||
forward-addr: 10.101.1.31@53
|
||||
|
||||
forward-zone:
|
||||
name: "srv."
|
||||
forward-addr: 10.101.1.31@53
|
||||
|
||||
remote-control:
|
||||
control-enable: yes
|
||||
control-interface: 127.0.0.1
|
||||
control-use-cert: no
|
||||
```
|
||||
|
||||
On Linux conf file devide on anoter files
|
||||
```sh
|
||||
sudo mcedit /etc/unbound/unbound.conf
|
||||
```
|
||||
|
||||
```sh
|
||||
cd /etc/unbound/ &&
|
||||
sudo mc
|
||||
```
|
||||
|
||||
Получить полный список локальных зон можно так: unbound-control
|
||||
```sh
|
||||
unbound-control list_local_zones
|
||||
```
|
||||
|
||||
```sh
|
||||
sudo systemctl restart unbound
|
||||
```
|
||||
|
||||
```sh
|
||||
sudo systemctl status unbound.service
|
||||
```
|
||||
```sh
|
||||
sudo journalctl -xeu unbound.service
|
||||
```
|
||||
|
||||
Check on errors:
|
||||
```sh
|
||||
sudo unbound-checkconf /etc/unbound/unbound.conf
|
||||
```
|
||||
|
||||
|
||||
Прописываем для определенного интерфейса:
|
||||
```sh
|
||||
sudo resolvectl dns wlp14s0 127.0.0.1
|
||||
```
|
||||
Проверяем что стоит в качестве NDS резольвера
|
||||
```sh
|
||||
resolvectl status
|
||||
```
|
||||
171
Logs/Vector_dev_install.md
Normal file
171
Logs/Vector_dev_install.md
Normal file
@ -0,0 +1,171 @@
|
||||
# Настройка Vector для отправки логов в Gotify
|
||||
|
||||
Эта инструкция описывает, как установить Vector, настроить его для чтения JSON-логов из файла `/opt/org_ccalm_main/logs/ccalm.log`, фильтрации строк с уровнем `ERROR` и отправки уведомлений в Gotify.
|
||||
|
||||
---
|
||||
## 0. ✅ Подключаемся к инфраструктуре
|
||||
|
||||
```sh
|
||||
ssh igor@ccalm.org -p 2200
|
||||
```
|
||||
|
||||
## Предварительные требования
|
||||
- ОС: Ubuntu/Debian (для других ОС уточните, чтобы адаптировать команды).
|
||||
- Файл логов: `/opt/org_ccalm_main/logs/ccalm.log` с JSON-строками (поля `level` и `message`).
|
||||
- Gotify: Доступный сервер Gotify с URL и токеном (например, `https://gotify.example.com/message?token=<your-token>`).
|
||||
- Доступ к терминалу с правами `sudo`.
|
||||
|
||||
|
||||
## Шаг 1: Установка Vector
|
||||
|
||||
Пробуем скачать deb пакет с сайта
|
||||
```sh
|
||||
curl -L https://packages.timber.io/vector/0.43.1/vector_0.43.1-1_amd64.deb -o vector_0.43.1-1_amd64.deb &&
|
||||
sudo dpkg -i vector_0.43.1-1_amd64.deb &&
|
||||
sudo apt-get install -f &&
|
||||
vector --version
|
||||
```
|
||||
|
||||
## Шаг 2: Создание конфигурации Vector
|
||||
Vector использует YAML для конфигурации. Настроим чтение логов, фильтрацию `ERROR` и отправку в Gotify.
|
||||
|
||||
1. Создайте файл конфигурации `/etc/vector/vector.yaml`:
|
||||
```sh
|
||||
cd /etc/vector &&
|
||||
sudo tee vector.yaml > /dev/null <<'EOF'
|
||||
data_dir: "/var/lib/vector"
|
||||
|
||||
sources:
|
||||
ccalm_logs:
|
||||
type: file
|
||||
include:
|
||||
- /opt/org_ccalm_main/logs/ccalm.log
|
||||
read_from: beginning
|
||||
|
||||
transforms:
|
||||
parse_json:
|
||||
type: remap
|
||||
inputs:
|
||||
- ccalm_logs
|
||||
source: |
|
||||
structured, err = parse_json(.message)
|
||||
if err != null {
|
||||
abort
|
||||
}
|
||||
merged, err = merge(., structured)
|
||||
if err != null {
|
||||
abort
|
||||
}
|
||||
. = merged
|
||||
|
||||
filter_errors:
|
||||
type: filter
|
||||
inputs:
|
||||
- parse_json
|
||||
condition: '.level == "ERROR"'
|
||||
|
||||
format_telegram_json:
|
||||
type: remap
|
||||
inputs:
|
||||
- filter_errors
|
||||
source: |
|
||||
msg, err = string(.message)
|
||||
if err != null {
|
||||
msg = "Unable to parse message"
|
||||
}
|
||||
.message = "{\"title\":\"CCALM Main Error Log\",\"message\":\"ERROR: " + msg + "\"}"
|
||||
|
||||
|
||||
sinks:
|
||||
gotify:
|
||||
type: http
|
||||
inputs:
|
||||
- filter_errors
|
||||
uri: "https://gotify.geovizor.top:8443/message?token=AYmcpr43YtPKDmZ"
|
||||
method: post
|
||||
encoding:
|
||||
codec: json
|
||||
template: '{"title":"CCALM Main Error Log","message":"Test message 00","priority":5}'
|
||||
request:
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
Host: "gotify.geovizor.top"
|
||||
Content-Length: "{{ content_length }}"
|
||||
tls:
|
||||
verify_certificate: false
|
||||
verify_hostname: false
|
||||
EOF
|
||||
```
|
||||
|
||||
Пробую отправку через curl
|
||||
```sh
|
||||
curl -X POST -k "https://gotify.geovizor.top:8443/message?token=AYmcpr43YtPKDmZ" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"message": "Test message", "priority": 5}'
|
||||
```
|
||||
|
||||
|
||||
Проверяем что gotify работает:
|
||||
```sh
|
||||
curl -k -X POST -H "Content-Type: application/json" -H "Host: gotify.geovizor.top" -d '{"message":"Test message 00","priority":5}' --http1.1 https://gotify.geovizor.top:8443/message?token=AYmcpr43YtPKDmZ -v
|
||||
```
|
||||
|
||||
### Объяснение конфигурации
|
||||
- **Source (`ccalm_logs`)**: Читает логи из файла, парсит JSON, поддерживает многострочные логи.
|
||||
- **Transform (`filter_errors`)**: Фильтрует логи с `level: "ERROR"`.
|
||||
- **Sink (`gotify`)**: Отправляет отфильтрованные логи в Gotify через HTTP POST.
|
||||
|
||||
## Шаг 3: Проверка конфигурации
|
||||
Проверьте корректность YAML:
|
||||
```sh
|
||||
vector --config /etc/vector/vector.yaml validate
|
||||
```
|
||||
Ожидаемый вывод: `Configuration is valid`.
|
||||
|
||||
## Шаг 4: Запуск Vector
|
||||
### Тестовый запуск (для отладки)
|
||||
```sh
|
||||
sudo vector --config /etc/vector/vector.yaml
|
||||
```
|
||||
|
||||
### Запуск как сервиса
|
||||
1. Включите и запустите сервис:
|
||||
```sh
|
||||
sudo systemctl enable vector
|
||||
sudo systemctl start vector
|
||||
```
|
||||
2. Проверьте статус:
|
||||
```sh
|
||||
sudo systemctl status vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Шаг 5: Проверка отправки в Gotify
|
||||
1. Убедитесь, что Gotify доступен по указанному URL.
|
||||
2. Добавьте тестовую строку лога в `/opt/org_ccalm_main/logs/ccalm.log`:
|
||||
```sh
|
||||
echo '{"level": "ERROR", "message": "Database connection failed", "timestamp": "2025-05-18T12:28:00Z"}' | sudo tee -a /opt/org_ccalm_main/logs/ccalm.log
|
||||
```
|
||||
3. Проверьте Gotify (веб-интерфейс или приложение) — должно прийти уведомление с заголовком "CCALM Log Error" и сообщением "Database connection failed".
|
||||
|
||||
## Шаг 6: Отладка
|
||||
- Логи Vector: `/var/log/vector/vector.log` или stdout (в тестовом режиме).
|
||||
- Проверьте логи при проблемах:
|
||||
```sh
|
||||
cat /var/log/vector/vector.log
|
||||
```
|
||||
|
||||
## Дополнительные настройки
|
||||
- **Права доступа к файлу логов**:
|
||||
```sh
|
||||
sudo chown vector:vector /opt/org_ccalm_main/logs/ccalm.log
|
||||
sudo chmod 644 /opt/org_ccalm_main/logs/ccalm.log
|
||||
```
|
||||
- **Если JSON-формат отличается**: Если поле `level` называется иначе (например, `log_level`), замените `.level` на `.log_level` в `condition`.
|
||||
- **HTTP вместо HTTPS**: Если Gotify использует HTTP, замените `https://` на `http://` в `uri`.
|
||||
|
||||
## Примечания
|
||||
- Убедитесь, что Gotify настроен и токен действителен.
|
||||
- Если логи не отправляются, проверьте сетевую доступность Gotify и правильность URL/токена.
|
||||
- Для чтения только новых логов удалите `read_from: beginning` в конфигурации.
|
||||
197
Logs/Vector_dev_install_telegram.md
Normal file
197
Logs/Vector_dev_install_telegram.md
Normal file
@ -0,0 +1,197 @@
|
||||
Шаг 1: Создание Telegram-бота
|
||||
Зарегистрируйте бота через BotFather:
|
||||
|
||||
Откройте Telegram и найдите @BotFather.
|
||||
Отправьте команду /start.
|
||||
Отправьте /newbot, чтобы создать нового бота.
|
||||
Следуйте инструкциям:
|
||||
Укажите имя бота (например, MyLogBot).
|
||||
Укажите username бота, заканчивающийся на bot (например, @MyLogAllBot).
|
||||
После создания вы получите токен (например, 8007457609:AAGnrXOSaoxODMSh4yCzUEIp0uxfH3Hk8ws). Сохраните его, он понадобится для API.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Настройка Vector для отправки логов в Gotify
|
||||
|
||||
Эта инструкция описывает, как установить Vector, настроить его для чтения JSON-логов из файла `/opt/org_ccalm_main/logs/ccalm.log`, фильтрации строк с уровнем `ERROR` и отправки уведомлений в Gotify.
|
||||
|
||||
---
|
||||
## 0. ✅ Подключаемся к инфраструктуре
|
||||
|
||||
```sh
|
||||
ssh igor@ccalm.org -p 2200
|
||||
```
|
||||
|
||||
## Предварительные требования
|
||||
- ОС: Ubuntu/Debian (для других ОС уточните, чтобы адаптировать команды).
|
||||
- Файл логов: `/opt/org_ccalm_main/logs/ccalm.log` с JSON-строками (поля `level` и `message`).
|
||||
- Gotify: Доступный сервер Gotify с URL и токеном (например, `https://gotify.example.com/message?token=<your-token>`).
|
||||
- Доступ к терминалу с правами `sudo`.
|
||||
|
||||
|
||||
## Шаг 1: Установка Vector
|
||||
|
||||
Пробуем скачать deb пакет с сайта
|
||||
|
||||
```sh
|
||||
curl -L https://packages.timber.io/vector/0.46.X/vector_0.46.1-1_amd64.deb -o vector_0.46.1-1_amd64.deb &&
|
||||
sudo dpkg -i vector_0.46.1-1_amd64.deb &&
|
||||
sudo apt-get install -f &&
|
||||
vector --version
|
||||
```
|
||||
|
||||
That make deleting:
|
||||
```sh
|
||||
sudo apt remove --purge vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Шаг 2: Создание конфигурации Vector
|
||||
Vector использует YAML для конфигурации. Настроим чтение логов, фильтрацию `ERROR` и отправку в Gotify.
|
||||
|
||||
1. Создайте файл конфигурации `/etc/vector/vector.yaml`:
|
||||
```sh
|
||||
cd /etc/vector &&
|
||||
sudo tee vector.yaml > /dev/null <<'EOF'
|
||||
data_dir: "/var/lib/vector"
|
||||
|
||||
sources:
|
||||
ccalm_logs:
|
||||
type: file
|
||||
include:
|
||||
- /opt/org_ccalm_main/logs/ccalm.log
|
||||
read_from: beginning
|
||||
|
||||
transforms:
|
||||
parse_json:
|
||||
type: remap
|
||||
inputs:
|
||||
- ccalm_logs
|
||||
source: |
|
||||
structured, err = parse_json(.message)
|
||||
if err != null {
|
||||
abort
|
||||
}
|
||||
merged, err = merge(., structured)
|
||||
if err != null {
|
||||
abort
|
||||
}
|
||||
. = merged
|
||||
|
||||
filter_errors:
|
||||
type: filter
|
||||
inputs:
|
||||
- parse_json
|
||||
condition: '.level == "ERROR"'
|
||||
|
||||
format_telegram_json:
|
||||
type: remap
|
||||
inputs:
|
||||
- filter_errors
|
||||
source: |
|
||||
msg, err = string(.message)
|
||||
if err != null {
|
||||
msg = "Unable to parse message"
|
||||
}
|
||||
.message = "{\"chat_id\":\"307675888\",\"text\":\"ERROR: " + msg + "\"}"
|
||||
|
||||
sinks:
|
||||
telegram:
|
||||
type: http
|
||||
inputs:
|
||||
- format_telegram_json
|
||||
uri: "https://api.telegram.org/bot8007457609:AAGnrXOSaoxODMSh4yCzUEIp0uxfH3Hk8ws/sendMessage"
|
||||
method: post
|
||||
encoding:
|
||||
codec: text
|
||||
request:
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
batch:
|
||||
max_events: 1
|
||||
|
||||
EOF
|
||||
```
|
||||
|
||||
curl https://api.telegram.org/bot8007457609:AAGnrXOSaoxODMSh4yCzUEIp0uxfH3Hk8ws/getUpdates
|
||||
|
||||
|
||||
Пробую отправку через curl
|
||||
```sh
|
||||
curl -X POST -k "https://gotify.geovizor.top:8443/message?token=AYmcpr43YtPKDmZ" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"message": "Test message", "priority": 5}'
|
||||
```
|
||||
|
||||
|
||||
Проверяем что gotify работает:
|
||||
```sh
|
||||
curl -k -X POST -H "Content-Type: application/json" -H "Host: gotify.geovizor.top" -d '{"message":"Test message 00","priority":5}' --http1.1 https://gotify.geovizor.top:8443/message?token=AYmcpr43YtPKDmZ -v
|
||||
```
|
||||
|
||||
### Объяснение конфигурации
|
||||
- **Source (`ccalm_logs`)**: Читает логи из файла, парсит JSON, поддерживает многострочные логи.
|
||||
- **Transform (`filter_errors`)**: Фильтрует логи с `level: "ERROR"`.
|
||||
- **Sink (`gotify`)**: Отправляет отфильтрованные логи в Gotify через HTTP POST.
|
||||
|
||||
## Шаг 3: Проверка конфигурации
|
||||
Проверьте корректность YAML:
|
||||
```sh
|
||||
vector --config /etc/vector/vector.yaml validate
|
||||
```
|
||||
Ожидаемый вывод: `Configuration is valid`.
|
||||
|
||||
## Шаг 4: Запуск Vector
|
||||
### Тестовый запуск (для отладки)
|
||||
```sh
|
||||
sudo vector --config /etc/vector/vector.yaml
|
||||
```
|
||||
|
||||
### Запуск как сервиса
|
||||
1. Включите и запустите сервис:
|
||||
```sh
|
||||
sudo systemctl enable vector
|
||||
sudo systemctl start vector
|
||||
```
|
||||
2. Проверьте статус:
|
||||
```sh
|
||||
sudo systemctl status vector
|
||||
```
|
||||
```sh
|
||||
sudo systemctl stop vector
|
||||
```
|
||||
|
||||
|
||||
## Шаг 5: Проверка отправки в Gotify
|
||||
1. Убедитесь, что Gotify доступен по указанному URL.
|
||||
2. Добавьте тестовую строку лога в `/opt/org_ccalm_main/logs/ccalm.log`:
|
||||
```sh
|
||||
echo '{"level": "ERROR", "message": "Database connection failed", "timestamp": "2025-05-18T12:28:00Z"}' | sudo tee -a /opt/org_ccalm_main/logs/ccalm.log
|
||||
```
|
||||
3. Проверьте Gotify (веб-интерфейс или приложение) — должно прийти уведомление с заголовком "CCALM Log Error" и сообщением "Database connection failed".
|
||||
|
||||
## Шаг 6: Отладка
|
||||
- Логи Vector: `/var/log/vector/vector.log` или stdout (в тестовом режиме).
|
||||
- Проверьте логи при проблемах:
|
||||
```sh
|
||||
cat /var/log/vector/vector.log
|
||||
```
|
||||
|
||||
## Дополнительные настройки
|
||||
- **Права доступа к файлу логов**:
|
||||
```sh
|
||||
sudo chown vector:vector /opt/org_ccalm_main/logs/ccalm.log
|
||||
sudo chmod 644 /opt/org_ccalm_main/logs/ccalm.log
|
||||
```
|
||||
- **Если JSON-формат отличается**: Если поле `level` называется иначе (например, `log_level`), замените `.level` на `.log_level` в `condition`.
|
||||
- **HTTP вместо HTTPS**: Если Gotify использует HTTP, замените `https://` на `http://` в `uri`.
|
||||
|
||||
## Примечания
|
||||
- Убедитесь, что Gotify настроен и токен действителен.
|
||||
- Если логи не отправляются, проверьте сетевую доступность Gotify и правильность URL/токена.
|
||||
- Для чтения только новых логов удалите `read_from: beginning` в конфигурации.
|
||||
@ -19,27 +19,33 @@ sudo apt-get install nginx -y
|
||||
```
|
||||
Самой важной строкой является Common Name (введите FQDN или свое имя). Как правило, в эту строку вносят доменное имя, с которым нужно связать сервер. В случае если доменного имени нет, внесите в эту строку IP-адрес сервера.
|
||||
```sh
|
||||
sudo openssl dhparam -out /etc/nginx/dhparam.pem 4096
|
||||
sudo openssl dhparam -out /etc/nginx/dhparam.pem 2048
|
||||
```
|
||||
|
||||
И вписываем в него:
|
||||
```sh
|
||||
cd /etc/nginx/sites-available/ &&
|
||||
sudo tee ccalm.org > /dev/null <<'EOF'
|
||||
server {
|
||||
listen 8081 ssl http2;
|
||||
listen [::]:8081 ssl http2;
|
||||
|
||||
server_name ccalm.org;
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
ssl_dhparam /etc/nginx/dhparam.pem;
|
||||
listen 8081;
|
||||
listen [::]:8081;
|
||||
|
||||
root /opt/www/org_ccalm;
|
||||
index index.html index.htm;
|
||||
index index.html;
|
||||
|
||||
server_name ccalm.org www.ccalm.org;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404; # Попытка найти файл или возвращение 404
|
||||
try_files $uri $uri/ =404;
|
||||
|
||||
# Оптимизация для быстрой отдачи статики
|
||||
sendfile on; # Использует sendfile() ядра Linux для ускорения
|
||||
tcp_nopush off; # Отключает задержку Nagle (если нужна мгновенная отправка)
|
||||
}
|
||||
location ~ /index\.html$ {
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires 0;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
@ -50,8 +56,6 @@ EOF
|
||||
sudo ln -s /etc/nginx/sites-available/ccalm.org /etc/nginx/sites-enabled/
|
||||
```
|
||||
|
||||
|
||||
|
||||
```sh
|
||||
sudo systemctl restart nginx
|
||||
```
|
||||
@ -79,17 +83,17 @@ journalctl -u nginx.service -n 50
|
||||
cd /etc/nginx/sites-available/ &&
|
||||
sudo tee geovizor.top > /dev/null <<'EOF'
|
||||
server {
|
||||
listen 8081;
|
||||
listen [::]:8081;
|
||||
listen 8081;
|
||||
listen [::]:8081;
|
||||
|
||||
root /opt/www/istransit.kz;
|
||||
index index.html;
|
||||
root /opt/www/istransit.kz;
|
||||
index index.html;
|
||||
|
||||
server_name istransit.kz www.istransit.kz;
|
||||
server_name istransit.kz www.istransit.kz;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
location ~ /index\.html$ {
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
|
||||
@ -1,66 +1,68 @@
|
||||
# Установка Uptime Kuma в Ubuntu 24.04 с помощью Docker Compose
|
||||
|
||||
## 1. Установка необходимых пакетов
|
||||
Обновите систему и установите Docker и Docker Compose:
|
||||
|
||||
```sh
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
sudo apt install -y docker.io docker-compose
|
||||
```
|
||||
|
||||
## 2. Создание директории для Uptime Kuma
|
||||
```sh
|
||||
sudo mkdir -p /opt/uptime-kuma
|
||||
cd /opt/uptime-kuma
|
||||
```
|
||||
|
||||
## 3. Создание `docker-compose.yml`
|
||||
Создайте файл `docker-compose.yml`:
|
||||
|
||||
```sh
|
||||
sudo mcedit /opt/uptime-kuma/docker-compose.yml
|
||||
```
|
||||
|
||||
Вставьте следующий конфигурационный файл:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
uptime-kuma:
|
||||
image: louislam/uptime-kuma:latest
|
||||
container_name: uptime-kuma
|
||||
restart: always
|
||||
ports:
|
||||
- "3001:3001"
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
```
|
||||
|
||||
## 4. Запуск контейнера
|
||||
```sh
|
||||
sudo docker-compose up -d
|
||||
```
|
||||
|
||||
## 5. Проверка работы Uptime Kuma
|
||||
Откройте браузер и перейдите по адресу:
|
||||
|
||||
```sh
|
||||
start http://192.168.200.84:3001
|
||||
```
|
||||
|
||||
## 6. Управление контейнером
|
||||
- **Остановить Uptime Kuma:**
|
||||
```sh
|
||||
sudo docker-compose down
|
||||
```
|
||||
- **Перезапустить контейнер:**
|
||||
```sh
|
||||
sudo docker-compose restart
|
||||
```
|
||||
- **Просмотреть логи:**
|
||||
|
||||
```sh
|
||||
sudo docker-compose logs -f
|
||||
```
|
||||
|
||||
Готово! Uptime Kuma установлен и запущен в Docker на Ubuntu 24.04. 🚀
|
||||
|
||||
# Установка Uptime Kuma в Ubuntu 24.04 с помощью Docker Compose
|
||||
|
||||
## 1. Установка необходимых пакетов
|
||||
Обновите систему и установите Docker и Docker Compose:
|
||||
|
||||
```sh
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
sudo apt install -y docker.io docker-compose
|
||||
```
|
||||
|
||||
## 2. Создание директории для Uptime Kuma
|
||||
```sh
|
||||
sudo mkdir -p /opt/uptime-kuma
|
||||
cd /opt/uptime-kuma
|
||||
```
|
||||
|
||||
## 3. Создание `docker-compose.yml`
|
||||
Создайте файл `docker-compose.yml`:
|
||||
|
||||
```sh
|
||||
sudo mcedit /opt/uptime-kuma/docker-compose.yml
|
||||
```
|
||||
|
||||
Вставьте следующий конфигурационный файл:
|
||||
В кодфиге прописан корневой сертификат чтобы node.js ему доверял
|
||||
```yaml
|
||||
services:
|
||||
uptime-kuma:
|
||||
image: louislam/uptime-kuma:latest
|
||||
container_name: uptime-kuma
|
||||
restart: always
|
||||
ports:
|
||||
- "3001:3001"
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
- /usr/local/share/ca-certificates:/usr/local/share/ca-certificates:ro
|
||||
environment:
|
||||
- NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/rootCA.crt
|
||||
```
|
||||
|
||||
## 4. Запуск контейнера
|
||||
```sh
|
||||
sudo docker-compose up -d
|
||||
```
|
||||
|
||||
## 5. Проверка работы Uptime Kuma
|
||||
Откройте браузер и перейдите по адресу:
|
||||
|
||||
```sh
|
||||
start http://192.168.200.84:3001
|
||||
```
|
||||
|
||||
## 6. Управление контейнером
|
||||
- **Остановить Uptime Kuma:**
|
||||
```sh
|
||||
sudo docker-compose down
|
||||
```
|
||||
- **Перезапустить контейнер:**
|
||||
```sh
|
||||
sudo docker-compose restart
|
||||
```
|
||||
- **Просмотреть логи:**
|
||||
|
||||
```sh
|
||||
sudo docker-compose logs -f
|
||||
```
|
||||
|
||||
Готово! Uptime Kuma установлен и запущен в Docker на Ubuntu 24.04. 🚀
|
||||
@ -1,260 +1,260 @@
|
||||
# 📌 Установка HAProxy на Ubuntu 20.04
|
||||
****************************************************************************************************
|
||||
На основе инструкции из https://itsecforu.ru/2019/07/15/⏳-настройка-балансировщика-нагрузки-h/
|
||||
|
||||
Connect to the required server:
|
||||
```sh
|
||||
ssh administrator@10.101.1.3 -p 22
|
||||
```
|
||||
Connect to CCALM Turkish infrastructure:
|
||||
```sh
|
||||
ssh igor@88.218.94.134 -p 2200
|
||||
```
|
||||
----------------------------------------------------------------------------------------------------
|
||||
## Install haproxy
|
||||
```sh
|
||||
sudo apt-get update && sudo apt-get install haproxy -y
|
||||
````
|
||||
Создаём резервную копию файла:
|
||||
```sh
|
||||
sudo cp /etc/haproxy/haproxy.cfg{,.bak}
|
||||
````
|
||||
Редактируем конфигурацию (Описание конфигурационного файла HAProxy https://habr.com/ru/sandbox/34354/)
|
||||
```sh
|
||||
mcedit /etc/haproxy/haproxy.cfg
|
||||
```
|
||||
В конец файла добавляем пока только для перенаправления (для балансироки больше IP адресов):
|
||||
```conf
|
||||
frontend frontend-http
|
||||
bind *:80
|
||||
mode http
|
||||
|
||||
# ACL для определения запросов на проверку Let's Encrypt
|
||||
acl is_certbot path_beg /.well-known/acme-challenge/
|
||||
|
||||
# Если это не запрос Let's Encrypt, перенаправляем на HTTPS
|
||||
http-request redirect scheme https code 301 unless is_certbot
|
||||
|
||||
# Отправляем запросы Let's Encrypt на backend-certbot
|
||||
use_backend backend-certbot if is_certbot
|
||||
|
||||
frontend LOADBALANCER-01
|
||||
bind *:80
|
||||
bind *:443 ssl crt /etc/haproxy/ssl/mqtt.kz.pem crt /etc/ssl/certs/bigfoottrade_kz.pem
|
||||
mode http #режим работы HAProxy, в http режиме происходит анализ Layer 7 трафика
|
||||
option httpclose #Закрывает пассивные соединения
|
||||
|
||||
http-request set-header x-Forwarded-for %[src]
|
||||
http-request set-header x-Forwarded-uri %[url]
|
||||
|
||||
acl v_geoserver2 hdr(host) -i geoserver2.ccalm.org
|
||||
use_backend geoserver2_ccalm_org if v_geoserver2
|
||||
|
||||
#Если различные нестандартные порты то так
|
||||
acl v_locust_kz hdr_reg(host) -i ^locust\.kz(:.*)?$
|
||||
use_backend b_locust_kz if v_locust_kz
|
||||
|
||||
#Перенаправление одной страницы по адресу http://geoserver2.ccalm.org/data/ на другой backend
|
||||
acl v_geo_data hdr(host) -i geoserver2.ccalm.org/data
|
||||
use_backend WEBSERVERS-01 if v_geo_data
|
||||
|
||||
default_backend WEBSERVER
|
||||
|
||||
backend WEBSERVER
|
||||
balance roundrobin
|
||||
server web1 127.0.0.1:8080 check inter 5s ssl verify none
|
||||
option httpchk GET /index.html
|
||||
|
||||
|
||||
backend geoserver2_ccalm_org
|
||||
balance roundrobin
|
||||
server web1 192.168.0.90:80 check
|
||||
option httpchk
|
||||
|
||||
listen stats
|
||||
bind *:8989
|
||||
stats enable
|
||||
stats uri /
|
||||
stats realm Haproxy\ Statistics
|
||||
stats auth igor:i123456
|
||||
|
||||
frontend f-RabbitMQ
|
||||
mode tcp
|
||||
bind 10.1.7.73:21000
|
||||
default_backend b-RabbitMQ
|
||||
|
||||
backend b-RabbitMQ
|
||||
mode tcp
|
||||
server srv1 10.10.16.21:20000
|
||||
```
|
||||
Для перенаправления незащищённого HTTP трафика можно: xxxxxxxxxxxxxxx
|
||||
|
||||
Для использования SSL и перенаправляние по обычному сокету для начала нужно настроить pem файл объеденив crt и key (и незабыть изменить порт Apache с 433)
|
||||
cat /etc/ssl/certs/bigfoottrade_kz.crt /etc/ssl/certs/bigfoottrade_kz_ca.crt /etc/ssl/private/bigfoottrade_kz.key > /etc/haproxy/ssl/bigfoottrade_kz.pem
|
||||
cat AAA_Certificate_Services.crt GoGetSSL_RSA_DV_CA.crt istransit_kz.crt istransit_kz.key > istransit_kz.pem
|
||||
|
||||
SSLCertificateFile
|
||||
SSLCertificateKeyFile
|
||||
|
||||
Для включения WEB статистики на 9000 порту добавить в конец конфигурации:
|
||||
listen stats
|
||||
bind *:8989
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats realm Haproxy\ Statistics
|
||||
stats auth igor:i123456
|
||||
Тестирую файл конфигурации:
|
||||
```sh
|
||||
haproxy -f /etc/haproxy/haproxy.cfg -c
|
||||
````
|
||||
Также можно в журнале посмотреть что написал HAProxy:
|
||||
```sh
|
||||
sudo journalctl -u haproxy --no-pager | tail -n 50
|
||||
````
|
||||
Перезагружаем:
|
||||
```sh
|
||||
sudo systemctl restart haproxy
|
||||
````
|
||||
|
||||
Посмотреть что в журнале можно так:
|
||||
Посмотреть что в журнале можно так:
|
||||
```sh
|
||||
journalctl -u haproxy --since "1 minutes ago"
|
||||
journalctl -u haproxy --since "30 minutes ago" | grep "backend"
|
||||
tail -f /var/log/haproxy.log
|
||||
```
|
||||
|
||||
|
||||
|
||||
administrator@app:~$ journalctl -u haproxy --since "30 minutes ago" | grep "backend"
|
||||
backend 'transit_acquiring_v01_kz' has no server available!
|
||||
backend 'transit_translation_v02_kz' has no server available!
|
||||
backend 'transit_mobile_kz' has no server available!
|
||||
backend 'transit_manager_kz' has no server available!
|
||||
backend 'transit_warehouse_kz' has no server available!
|
||||
backend 'transit_kgd_kz' has no server available!
|
||||
backend 'transit_monitoring_kz' has no server available!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
И теперь должно открываться но адресу: http://data.ccalm.org:8989/
|
||||
Обязательно проверить как установился SSL чекером: https://www.leaderssl.ru/tools/ssl_checker
|
||||
|
||||
|
||||
# 📌 Бесплатный SSL сертификат Let’s Encrypt для HAPROXY
|
||||
****************************************************************************************************
|
||||
Бесплатный SSL сертификат Let’s Encrypt для HAPROXY https://serversforhackers.com/c/letsencrypt-with-haproxy
|
||||
```sh
|
||||
sudo apt-get update
|
||||
sudo apt-get install certbot -y
|
||||
````
|
||||
Для удаления PPA нужно выполнить:
|
||||
```sh
|
||||
sudo apt-get remove certbot
|
||||
sudo add-apt-repository --remove ppa:certbot/certbot
|
||||
apt-get install -f
|
||||
apt autoremove
|
||||
```
|
||||
Если включён файрволл то разрешаем порт:
|
||||
```sh
|
||||
sudo ufw allow 9080/tcp
|
||||
```
|
||||
Проверяем что автообновление в certbot работает для этого выполняем команду:
|
||||
```sh
|
||||
sudo systemctl status certbot.timer
|
||||
```
|
||||
Затем пытаемся выполнить пробный прогон при помощи команды:
|
||||
```sh
|
||||
sudo certbot renew --dry-run
|
||||
```
|
||||
|
||||
Согласно инструкции модифицируем конфигурационный файл haproxy добавив во frontend это:
|
||||
```
|
||||
# ACL for detecting Let's Encrypt validtion requests
|
||||
acl is_certbot path_beg /.well-known/acme-challenge/
|
||||
use_backend backend-certbot if is_certbot
|
||||
```
|
||||
А также ещё один backend:
|
||||
```
|
||||
# Certbot backend
|
||||
# Contains certbot stand-alone webserver
|
||||
backend backend-certbot
|
||||
mode http
|
||||
server certbot 127.0.0.1:9080
|
||||
```
|
||||
Перезагрузить и выполнить команду:
|
||||
|
||||
```sh
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d powerdns.geovizor.top --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geovizor.top --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d locust.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d gotify.locust.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d git.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d ru.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d rug.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d kz.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d kzg.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d locust.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d test.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d data.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geoserver2.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geoserver.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d stations.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d uspdmanager.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d tourist.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d monitoring.infracos.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d aistransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d istransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d test.istransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d main.istransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d transit.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geovizor.com --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d mqtt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d observer.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d rigor.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d pal.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d elektronnaya-ochered.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d mcp.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
```
|
||||
|
||||
После генерации файлы будут в:
|
||||
/etc/letsencrypt/live/geoserver2.ccalm.org/fullchain.pem
|
||||
/etc/letsencrypt/live/geoserver2.ccalm.org/privkey.pem
|
||||
|
||||
Для обновления создаём файл /etc/letsencrypt/renew.sh (по моему этот скрипт не нужен так как рабтает сервис certbot.timer):
|
||||
#!/bin/bash
|
||||
certbot renew --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 --post-hook "/etc/haproxy/prepare.sh" --quiet
|
||||
|
||||
Но для HAProxy нужно чтобы 2 файла были объединены поэтому добавляю спец скрипт /etc/haproxy/prepare.sh:
|
||||
#!/bin/bash
|
||||
|
||||
# Loop through all Let's Encrypt certificates
|
||||
for CERTIFICATE in `find /etc/letsencrypt/live/* -type d`; do
|
||||
|
||||
CERTIFICATE=`basename $CERTIFICATE`
|
||||
|
||||
# Combine certificate and private key to single file
|
||||
cat /etc/letsencrypt/live/$CERTIFICATE/fullchain.pem /etc/letsencrypt/live/$CERTIFICATE/privkey.pem > /etc/haproxy/ssl/$CERTIFICATE.pem
|
||||
|
||||
done
|
||||
systemctl reload haproxy.service
|
||||
|
||||
Обновляем конфигурацию HAProxy добавив в frontend:
|
||||
bind *:443 ssl crt /etc/haproxy/ssl/mqtt.kz.pem
|
||||
|
||||
Устанавливаем права
|
||||
chmod +x /etc/haproxy/renew.sh
|
||||
chmod +x /etc/haproxy/prepare.sh
|
||||
И добавляем задание в cron "crontab -e" ниже текст это раз в 24 часа в 00:00:00 ночи:
|
||||
0 0 * * * /bin/sh /etc/letsencrypt/renew.sh
|
||||
# 📌 Установка HAProxy на Ubuntu 20.04
|
||||
****************************************************************************************************
|
||||
На основе инструкции из https://itsecforu.ru/2019/07/15/⏳-настройка-балансировщика-нагрузки-h/
|
||||
|
||||
Connect to the required server:
|
||||
```sh
|
||||
ssh administrator@10.101.1.3 -p 22
|
||||
```
|
||||
Connect to CCALM Turkish infrastructure:
|
||||
```sh
|
||||
ssh igor@88.218.94.134 -p 2200
|
||||
```
|
||||
----------------------------------------------------------------------------------------------------
|
||||
## Install haproxy
|
||||
```sh
|
||||
sudo apt-get update && sudo apt-get install haproxy -y
|
||||
````
|
||||
Создаём резервную копию файла:
|
||||
```sh
|
||||
sudo cp /etc/haproxy/haproxy.cfg{,.bak}
|
||||
````
|
||||
Редактируем конфигурацию (Описание конфигурационного файла HAProxy https://habr.com/ru/sandbox/34354/)
|
||||
```sh
|
||||
mcedit /etc/haproxy/haproxy.cfg
|
||||
```
|
||||
В конец файла добавляем пока только для перенаправления (для балансироки больше IP адресов):
|
||||
```conf
|
||||
frontend frontend-http
|
||||
bind *:80
|
||||
mode http
|
||||
|
||||
# ACL для определения запросов на проверку Let's Encrypt
|
||||
acl is_certbot path_beg /.well-known/acme-challenge/
|
||||
|
||||
# Если это не запрос Let's Encrypt, перенаправляем на HTTPS
|
||||
http-request redirect scheme https code 301 unless is_certbot
|
||||
|
||||
# Отправляем запросы Let's Encrypt на backend-certbot
|
||||
use_backend backend-certbot if is_certbot
|
||||
|
||||
frontend LOADBALANCER-01
|
||||
bind *:80
|
||||
bind *:443 ssl crt /etc/haproxy/ssl/mqtt.kz.pem crt /etc/ssl/certs/bigfoottrade_kz.pem
|
||||
mode http #режим работы HAProxy, в http режиме происходит анализ Layer 7 трафика
|
||||
option httpclose #Закрывает пассивные соединения
|
||||
|
||||
http-request set-header x-Forwarded-for %[src]
|
||||
http-request set-header x-Forwarded-uri %[url]
|
||||
|
||||
acl v_geoserver2 hdr(host) -i geoserver2.ccalm.org
|
||||
use_backend geoserver2_ccalm_org if v_geoserver2
|
||||
|
||||
#Если различные нестандартные порты то так
|
||||
acl v_locust_kz hdr_reg(host) -i ^locust\.kz(:.*)?$
|
||||
use_backend b_locust_kz if v_locust_kz
|
||||
|
||||
#Перенаправление одной страницы по адресу http://geoserver2.ccalm.org/data/ на другой backend
|
||||
acl v_geo_data hdr(host) -i geoserver2.ccalm.org/data
|
||||
use_backend WEBSERVERS-01 if v_geo_data
|
||||
|
||||
default_backend WEBSERVER
|
||||
|
||||
backend WEBSERVER
|
||||
balance roundrobin
|
||||
server web1 127.0.0.1:8080 check inter 5s ssl verify none
|
||||
option httpchk GET /index.html
|
||||
|
||||
|
||||
backend geoserver2_ccalm_org
|
||||
balance roundrobin
|
||||
server web1 192.168.0.90:80 check
|
||||
option httpchk
|
||||
|
||||
listen stats
|
||||
bind *:8989
|
||||
stats enable
|
||||
stats uri /
|
||||
stats realm Haproxy\ Statistics
|
||||
stats auth igor:i123456
|
||||
|
||||
frontend f-RabbitMQ
|
||||
mode tcp
|
||||
bind 10.1.7.73:21000
|
||||
default_backend b-RabbitMQ
|
||||
|
||||
backend b-RabbitMQ
|
||||
mode tcp
|
||||
server srv1 10.10.16.21:20000
|
||||
```
|
||||
Для перенаправления незащищённого HTTP трафика можно: xxxxxxxxxxxxxxx
|
||||
|
||||
Для использования SSL и перенаправляние по обычному сокету для начала нужно настроить pem файл объеденив crt и key (и незабыть изменить порт Apache с 433)
|
||||
cat /etc/ssl/certs/bigfoottrade_kz.crt /etc/ssl/certs/bigfoottrade_kz_ca.crt /etc/ssl/private/bigfoottrade_kz.key > /etc/haproxy/ssl/bigfoottrade_kz.pem
|
||||
cat AAA_Certificate_Services.crt GoGetSSL_RSA_DV_CA.crt istransit_kz.crt istransit_kz.key > istransit_kz.pem
|
||||
|
||||
SSLCertificateFile
|
||||
SSLCertificateKeyFile
|
||||
|
||||
Для включения WEB статистики на 9000 порту добавить в конец конфигурации:
|
||||
listen stats
|
||||
bind *:8989
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats realm Haproxy\ Statistics
|
||||
stats auth igor:i123456
|
||||
Тестирую файл конфигурации:
|
||||
```sh
|
||||
haproxy -f /etc/haproxy/haproxy.cfg -c
|
||||
````
|
||||
Также можно в журнале посмотреть что написал HAProxy:
|
||||
```sh
|
||||
sudo journalctl -u haproxy --no-pager -n 50 -f
|
||||
````
|
||||
Перезагружаем:
|
||||
```sh
|
||||
sudo systemctl restart haproxy
|
||||
````
|
||||
|
||||
Посмотреть что в журнале можно так:
|
||||
Посмотреть что в журнале можно так:
|
||||
```sh
|
||||
journalctl -u haproxy --since "1 minutes ago"
|
||||
journalctl -u haproxy --since "30 minutes ago" | grep "backend"
|
||||
tail -f /var/log/haproxy.log
|
||||
```
|
||||
|
||||
|
||||
|
||||
administrator@app:~$ journalctl -u haproxy --since "30 minutes ago" | grep "backend"
|
||||
backend 'transit_acquiring_v01_kz' has no server available!
|
||||
backend 'transit_translation_v02_kz' has no server available!
|
||||
backend 'transit_mobile_kz' has no server available!
|
||||
backend 'transit_manager_kz' has no server available!
|
||||
backend 'transit_warehouse_kz' has no server available!
|
||||
backend 'transit_kgd_kz' has no server available!
|
||||
backend 'transit_monitoring_kz' has no server available!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
И теперь должно открываться но адресу: http://data.ccalm.org:8989/
|
||||
Обязательно проверить как установился SSL чекером: https://www.leaderssl.ru/tools/ssl_checker
|
||||
|
||||
|
||||
# 📌 Бесплатный SSL сертификат Let’s Encrypt для HAPROXY
|
||||
****************************************************************************************************
|
||||
Бесплатный SSL сертификат Let’s Encrypt для HAPROXY https://serversforhackers.com/c/letsencrypt-with-haproxy
|
||||
```sh
|
||||
sudo apt-get update
|
||||
sudo apt-get install certbot -y
|
||||
````
|
||||
Для удаления PPA нужно выполнить:
|
||||
```sh
|
||||
sudo apt-get remove certbot
|
||||
sudo add-apt-repository --remove ppa:certbot/certbot
|
||||
apt-get install -f
|
||||
apt autoremove
|
||||
```
|
||||
Если включён файрволл то разрешаем порт:
|
||||
```sh
|
||||
sudo ufw allow 9080/tcp
|
||||
```
|
||||
Проверяем что автообновление в certbot работает для этого выполняем команду:
|
||||
```sh
|
||||
sudo systemctl status certbot.timer
|
||||
```
|
||||
Затем пытаемся выполнить пробный прогон при помощи команды:
|
||||
```sh
|
||||
sudo certbot renew --dry-run
|
||||
```
|
||||
|
||||
Согласно инструкции модифицируем конфигурационный файл haproxy добавив во frontend это:
|
||||
```
|
||||
# ACL for detecting Let's Encrypt validtion requests
|
||||
acl is_certbot path_beg /.well-known/acme-challenge/
|
||||
use_backend backend-certbot if is_certbot
|
||||
```
|
||||
А также ещё один backend:
|
||||
```
|
||||
# Certbot backend
|
||||
# Contains certbot stand-alone webserver
|
||||
backend backend-certbot
|
||||
mode http
|
||||
server certbot 127.0.0.1:9080
|
||||
```
|
||||
Перезагрузить и выполнить команду:
|
||||
|
||||
```sh
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d powerdns.geovizor.top --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geovizor.top --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d locust.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d gotify.locust.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d git.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d ru.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d rug.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d kz.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d kzg.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d locust.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d test.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d data.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geoserver2.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geoserver.ccalm.org --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d stations.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d uspdmanager.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d tourist.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d monitoring.infracos.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d aistransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d istransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d test.istransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d main.istransit.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d transit.istt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d geovizor.com --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d mqtt.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d observer.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d rigor.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d pal.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d elektronnaya-ochered.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
certbot certonly --rsa-key-size 2048 --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 -d mcp.kz --email irigm@mail.ru --agree-tos --non-interactive
|
||||
```
|
||||
|
||||
После генерации файлы будут в:
|
||||
/etc/letsencrypt/live/geoserver2.ccalm.org/fullchain.pem
|
||||
/etc/letsencrypt/live/geoserver2.ccalm.org/privkey.pem
|
||||
|
||||
Для обновления создаём файл /etc/letsencrypt/renew.sh (по моему этот скрипт не нужен так как рабтает сервис certbot.timer):
|
||||
#!/bin/bash
|
||||
certbot renew --standalone --preferred-challenges http --http-01-address 127.0.0.1 --http-01-port 9080 --post-hook "/etc/haproxy/prepare.sh" --quiet
|
||||
|
||||
Но для HAProxy нужно чтобы 2 файла были объединены поэтому добавляю спец скрипт /etc/haproxy/prepare.sh:
|
||||
#!/bin/bash
|
||||
|
||||
# Loop through all Let's Encrypt certificates
|
||||
for CERTIFICATE in `find /etc/letsencrypt/live/* -type d`; do
|
||||
|
||||
CERTIFICATE=`basename $CERTIFICATE`
|
||||
|
||||
# Combine certificate and private key to single file
|
||||
cat /etc/letsencrypt/live/$CERTIFICATE/fullchain.pem /etc/letsencrypt/live/$CERTIFICATE/privkey.pem > /etc/haproxy/ssl/$CERTIFICATE.pem
|
||||
|
||||
done
|
||||
systemctl reload haproxy.service
|
||||
|
||||
Обновляем конфигурацию HAProxy добавив в frontend:
|
||||
bind *:443 ssl crt /etc/haproxy/ssl/mqtt.kz.pem
|
||||
|
||||
Устанавливаем права
|
||||
chmod +x /etc/haproxy/renew.sh
|
||||
chmod +x /etc/haproxy/prepare.sh
|
||||
И добавляем задание в cron "crontab -e" ниже текст это раз в 24 часа в 00:00:00 ночи:
|
||||
0 0 * * * /bin/sh /etc/letsencrypt/renew.sh
|
||||
@ -1,8 +1,10 @@
|
||||
С внешки во внутрянную инфраструктуру подключаемся через HAProxy а уже внутри использую Traefik
|
||||
|
||||
Открываю нужный сервер
|
||||
```sh
|
||||
wsl
|
||||
```
|
||||
Или такой:
|
||||
Открывает traefik на 192.168.200.85:
|
||||
```sh
|
||||
ssh igor@192.168.200.85 -p 22
|
||||
```
|
||||
@ -155,6 +157,13 @@ http:
|
||||
service: local_powerdns
|
||||
tls: {}
|
||||
|
||||
gotify:
|
||||
entryPoints:
|
||||
- websecure
|
||||
rule: "Host(`gotify.local`)"
|
||||
service: local_gotify
|
||||
tls: {}
|
||||
|
||||
middlewares:
|
||||
strip-auth-prefix:
|
||||
stripPrefix:
|
||||
@ -180,6 +189,16 @@ http:
|
||||
path: "/"
|
||||
interval: "5s"
|
||||
|
||||
# Бэкенд для local_gotify
|
||||
local_gotify:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "https://192.168.200.84:8080"
|
||||
serversTransport: insecureTransport
|
||||
healthCheck:
|
||||
path: "/"
|
||||
interval: "5s"
|
||||
|
||||
# Бэкенд для org_ccalm_api_authorization_v02 (HTTPS с отключенной проверкой SSL)
|
||||
org_ccalm_api_authorization_v02:
|
||||
loadBalancer:
|
||||
@ -243,6 +262,8 @@ tls:
|
||||
keyFile: "/etc/traefik/certs/ccalm.test.key"
|
||||
- certFile: "/etc/traefik/certs/powerdns.local.crt"
|
||||
keyFile: "/etc/traefik/certs/powerdns.local.key"
|
||||
- certFile: "/etc/traefik/certs/gotify.local.crt"
|
||||
keyFile: "/etc/traefik/certs/gotify.local.key"
|
||||
- certFile: "/etc/traefik/certs/wildcard.local.crt"
|
||||
keyFile: "/etc/traefik/certs/wildcard.local.key"
|
||||
- certFile: "/etc/traefik/certs/wildcard.test.crt"
|
||||
@ -79,6 +79,17 @@ openssl x509 -in powerdns.local.crt -text -noout
|
||||
```
|
||||
|
||||
|
||||
Создаём и подписываем одной группой команд:
|
||||
```sh
|
||||
openssl version &&
|
||||
openssl genrsa -out gotify.local.key 2048 &&
|
||||
openssl req -new -key gotify.local.key -out gotify.local.csr -subj "/CN=gotify.local" -addext "subjectAltName=DNS:gotify.local" &&
|
||||
openssl x509 -req -in gotify.local.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out gotify.local.crt -days 365 -sha256 -copy_extensions copy &&
|
||||
openssl x509 -in gotify.local.crt -text -noout &&
|
||||
cat gotify.local.crt gotify.local.key > gotify.local.pem
|
||||
```
|
||||
Теперь можно устанавливать в HAProxy этот gotify.local.pem сертификат
|
||||
|
||||
|
||||
|
||||
Подписать корневым CA:
|
||||
@ -1,361 +1,361 @@
|
||||
# Установка HashiCorp Vault на Ubuntu
|
||||
|
||||
Vault — это инструмент от HashiCorp для безопасного хранения секретов и управления ими.
|
||||
|
||||
## 1. Установка Vault
|
||||
|
||||
Открываю нужный сервер
|
||||
```sh
|
||||
wsl
|
||||
```
|
||||
Похоже vault из Москвы недоступен:
|
||||
```sh
|
||||
ssh root@45.144.64.218 -p 2200
|
||||
```
|
||||
|
||||
### 1.1. Добавление репозитория HashiCorp
|
||||
|
||||
1. Установите необходимые пакеты:
|
||||
```sh
|
||||
sudo apt update && sudo apt install -y gnupg software-properties-common curl
|
||||
```
|
||||
|
||||
2. Добавьте официальный GPG-ключ HashiCorp:
|
||||
```sh
|
||||
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
||||
```
|
||||
|
||||
3. Добавьте репозиторий HashiCorp в систему:
|
||||
```sh
|
||||
sudo mcedit /etc/apt/sources.list.d/hashicorp.list
|
||||
```
|
||||
|
||||
Заменяем на:
|
||||
```text
|
||||
deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com noble main
|
||||
```
|
||||
Где noble это кодовое имя Ubuntu 24.04
|
||||
|
||||
|
||||
4. Обновите списки пакетов:
|
||||
```sh
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
5. Установите Vault:
|
||||
```sh
|
||||
sudo apt install -y vault
|
||||
```
|
||||
|
||||
6. Проверьте, что Vault установлен правильно:
|
||||
```sh
|
||||
vault --version
|
||||
```
|
||||
Выдало: Vault v1.18.5 (2cb3755273dbd63f5b0f8ec50089b57ffd3fa330), built 2025-02-24T09:40:28Z
|
||||
|
||||
|
||||
## 2. Запуск Vault
|
||||
|
||||
### 2.1. Запуск в Dev-режиме (только для тестирования)
|
||||
|
||||
If work stop it:
|
||||
```sh
|
||||
sudo pkill vault
|
||||
```
|
||||
If need delete old data:
|
||||
```sh
|
||||
sudo rm -rf ~/.vault-token ~/.vault/
|
||||
```
|
||||
For find where stored data read file:
|
||||
```sh
|
||||
sudo mcedit /etc/vault/config.hcl
|
||||
```
|
||||
In config file find this path: /opt/vault/data
|
||||
|
||||
После удаления базы нужно инициализировать Vault заново:
|
||||
```sh
|
||||
sudo vault operator init
|
||||
```
|
||||
|
||||
Run in developer mode (in dev mode data stored in RAM):
|
||||
```sh
|
||||
vault server -dev
|
||||
```
|
||||
|
||||
```text
|
||||
WARNING! dev mode is enabled! In this mode, Vault runs entirely in-memory
|
||||
and starts unsealed with a single unseal key. The root token is already
|
||||
authenticated to the CLI, so you can immediately begin using Vault.
|
||||
|
||||
You may need to set the following environment variables:
|
||||
|
||||
$ export VAULT_ADDR='http://127.0.0.1:8200'
|
||||
|
||||
The unseal key and root token are displayed below in case you want to
|
||||
seal/unseal the Vault or re-authenticate.
|
||||
|
||||
Unseal Key: TMb6A3QI3wJ9kaEeTYo5wEviP23lugJ3Asek2la6V4s=
|
||||
Root Token: hvs.GsWHRR7ne7gMTZhuPgZdh91w
|
||||
|
||||
Development mode should NOT be used in production installations!
|
||||
```
|
||||
|
||||
Теперь Vault работает по адресу:
|
||||
```sh
|
||||
start http://127.0.0.1:8200
|
||||
```
|
||||
Останавливаю нажатием Ctrl + C
|
||||
|
||||
|
||||
### 2.2. Настройка Vault в режиме сервера
|
||||
|
||||
1. Создайте конфигурационный файл:
|
||||
```sh
|
||||
sudo mkdir -p /etc/vault &&
|
||||
sudo mcedit /etc/vault/config.hcl
|
||||
```
|
||||
|
||||
2. Добавьте следующий конфиг:
|
||||
```text
|
||||
storage "file" {
|
||||
path = "/opt/vault/data"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "127.0.0.1:8200"
|
||||
tls_disable = 1
|
||||
}
|
||||
|
||||
disable_mlock = true
|
||||
ui = true
|
||||
```
|
||||
|
||||
3. Создайте папку для хранения данных:
|
||||
```sh
|
||||
sudo mkdir -p /opt/vault/data &&
|
||||
sudo chown vault:vault /opt/vault/data
|
||||
```
|
||||
|
||||
4. Создайте systemd-сервис для Vault:
|
||||
```sh
|
||||
sudo tee /etc/systemd/system/vault.service > /dev/null <<'EOF'
|
||||
[Unit]
|
||||
Description=HashiCorp Vault
|
||||
After=network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
User=vault
|
||||
Group=vault
|
||||
ExecStart=/usr/bin/vault server -config=/etc/vault/config.hcl
|
||||
ExecReload=/bin/kill --signal HUP \$MAINPID
|
||||
KillSignal=SIGTERM
|
||||
Restart=on-failure
|
||||
LimitMEMLOCK=infinity
|
||||
ProtectSystem=full
|
||||
CapabilityBoundingSet=CAP_IPC_LOCK CAP_SETGID CAP_SETUID CAP_SYSLOG CAP_CHOWN
|
||||
NoNewPrivileges=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
```
|
||||
Проверяем всё ли записалось:
|
||||
```sh
|
||||
sudo mcedit /etc/systemd/system/vault.service
|
||||
```
|
||||
|
||||
5. Перезапустите systemd и включите Vault:
|
||||
```sh
|
||||
sudo systemctl daemon-reload &&
|
||||
sudo systemctl enable vault &&
|
||||
sudo systemctl start vault
|
||||
```
|
||||
|
||||
7. Проверьте статус:
|
||||
```sh
|
||||
sudo systemctl status vault
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Инициализация и разлочка Vault
|
||||
|
||||
1. Экспортируйте переменную окружения:
|
||||
```sh
|
||||
export VAULT_ADDR='http://127.0.0.1:8200'
|
||||
```
|
||||
|
||||
2. Инициализируйте хранилище (сохраните ключи!):
|
||||
```sh
|
||||
vault operator init
|
||||
```
|
||||
|
||||
Выдало:
|
||||
```text
|
||||
Unseal Key 1: lQlJsb9RI8rSzLrc5iPnx1qJkWZbbXIkrEgnQGe5R6uO
|
||||
Unseal Key 2: 0qJJXRo570jlH/0Qs/wodXHNI2SF5VgL4jE04JawSPSB
|
||||
Unseal Key 3: VuYkOkQ8qmwofDmjqsTRQoMqGAH3Jv+nqQylL7Uibbtp
|
||||
Unseal Key 4: JJJ8Nqj00qzS9u5wNtTtExL/jWlJF9fgaBsiuaf0kFxC
|
||||
Unseal Key 5: L6lZMp/l7s24EZJAFnWS4Py5jsWOuMioC41g5LhUJKWL
|
||||
|
||||
Initial Root Token: hvs.o07DY7tnSPcufxk60pjCXDzn
|
||||
|
||||
Vault initialized with 5 key shares and a key threshold of 3. Please securely
|
||||
distribute the key shares printed above. When the Vault is re-sealed,
|
||||
restarted, or stopped, you must supply at least 3 of these keys to unseal it
|
||||
before it can start servicing requests.
|
||||
|
||||
Vault does not store the generated root key. Without at least 3 keys to
|
||||
reconstruct the root key, Vault will remain permanently sealed!
|
||||
|
||||
It is possible to generate new unseal keys, provided you have a quorum of
|
||||
existing unseal keys shares. See "vault operator rekey" for more information.
|
||||
```
|
||||
|
||||
3. Разблокируйте Vault, используя один из ключей (потом ещё 3 раза выполнить эту команду):
|
||||
```sh
|
||||
vault operator unseal
|
||||
```
|
||||
|
||||
4. Авторизуйтесь с root-токеном:
|
||||
```sh
|
||||
vault login hvs.MTFV72PjKXCVh5ZL6yCVE3Yw
|
||||
```
|
||||
|
||||
5. Создаём(включаем) новое хранилище ключ-значение через ssh
|
||||
```sh
|
||||
vault secrets enable -path=org-ccalm kv-v2
|
||||
```
|
||||
|
||||
|
||||
|
||||
5. Writing to the kv storage (добавил префикс vault. чтобы значения самому подставлять в нужные места в spring)
|
||||
|
||||
Заменит(создаст) значение:
|
||||
```sh
|
||||
vault kv put org-ccalm/jwt vault.server.ssl.key-store-password=MFNX344yh4
|
||||
```
|
||||
Добавит (обновит):
|
||||
```sh
|
||||
vault kv patch org-ccalm/jwt vault.test=test2
|
||||
```
|
||||
```sh
|
||||
vault kv put org-ccalm/public vault.personal_data.key=7dd2Nek1
|
||||
```
|
||||
|
||||
6. Read data from the kv
|
||||
```sh
|
||||
vault kv get org-ccalm/jwt
|
||||
```
|
||||
|
||||
Должно вывести:
|
||||
```text
|
||||
Key Value
|
||||
--- -----
|
||||
server.ssl.key-store-password M4yh4
|
||||
```
|
||||
|
||||
6. Включаем AppRole для доступа из приложения
|
||||
```sh
|
||||
vault auth enable approle
|
||||
```
|
||||
|
||||
7. Добавляем политики потом создаём ключ для этой политикиполитики
|
||||
|
||||
Создаю файл политик
|
||||
```sh
|
||||
cd ~ &&
|
||||
sudo tee jwt-policy.hcl > /dev/null <<'EOF'
|
||||
path "org-ccalm/data/jwt" {
|
||||
capabilities = ["create", "read", "update", "delete", "list"]
|
||||
}
|
||||
path "org-ccalm/data/public" {
|
||||
capabilities = ["read", "list"]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
Apply and delete configiration file:
|
||||
```sh
|
||||
vault policy write jwt-policy ~/jwt-policy.hcl &&
|
||||
rm -f jwt-policy.hcl
|
||||
```
|
||||
|
||||
Создаём AppRole (на 10 лет)
|
||||
```sh
|
||||
vault write auth/approle/role/org-ccalm-jwt \
|
||||
secret_id_ttl=0 \
|
||||
token_ttl=87600h \
|
||||
token_max_ttl=87600h \
|
||||
policies="jwt-policy,another-policy,third-policy"
|
||||
```
|
||||
|
||||
Получаем role_id и secret_id
|
||||
```sh
|
||||
vault read auth/approle/role/org-ccalm-jwt/role-id
|
||||
```
|
||||
Выдало
|
||||
```text
|
||||
Key Value
|
||||
--- -----
|
||||
role_id c0064fe2-8f0e-b317-7fe7-66f7405b45a1
|
||||
```
|
||||
На команду
|
||||
```sh
|
||||
vault write -f auth/approle/role/org-ccalm-jwt/secret-id
|
||||
```
|
||||
Выдало:
|
||||
```text
|
||||
Key Value
|
||||
--- -----
|
||||
secret_id 24f31c88-7185-0d93-9a51-e221c2925265
|
||||
secret_id_accessor 22fa68e3-fc73-2008-0a34-3506630b6693
|
||||
secret_id_num_uses 0
|
||||
secret_id_ttl 0s
|
||||
```
|
||||
Сохрани role_id и secret_id, они понадобятся Spring Boot.
|
||||
|
||||
Хранить ключи лучьше в переменных окружения
|
||||
```sh
|
||||
export VAULT_ROLE_ID="your-role-id" &&
|
||||
export VAULT_SECRET_ID="your-secret-id"
|
||||
```
|
||||
|
||||
|
||||
Проверяем не больше какого значения можно задать время жизни кокена:
|
||||
```sh
|
||||
vault read sys/mounts/auth/token/tune
|
||||
```
|
||||
По умолчанию max_lease_ttl равен 32 дня!
|
||||
|
||||
На год можно увеличить так:
|
||||
```sh
|
||||
vault write sys/mounts/auth/token/tune max_lease_ttl=8760h
|
||||
```
|
||||
|
||||
Create data access token with set politics:
|
||||
```sh
|
||||
vault token create -policy=jwt-policy -ttl=0
|
||||
```
|
||||
|
||||
Продлевать токен можно так:
|
||||
```sh
|
||||
vault token renew <твой-токен>
|
||||
```
|
||||
|
||||
Проверяем зранятся ли токены в хранилище а не в памяти
|
||||
```sh
|
||||
vault read sys/auth/token/tune
|
||||
```
|
||||
token_type = default-service, значит Vault не хранит токены
|
||||
|
||||
Включаем хранение токенов:
|
||||
```sh
|
||||
vault write sys/auth/token/tune token_type=service
|
||||
```
|
||||
|
||||
|
||||
|
||||
---
|
||||
Теперь HashiCorp Vault установлен и готов к использованию! 🚀
|
||||
|
||||
# Установка HashiCorp Vault на Ubuntu
|
||||
|
||||
Vault — это инструмент от HashiCorp для безопасного хранения секретов и управления ими.
|
||||
|
||||
## 1. Установка Vault
|
||||
|
||||
Открываю нужный сервер
|
||||
```sh
|
||||
wsl
|
||||
```
|
||||
Похоже vault из Москвы недоступен:
|
||||
```sh
|
||||
ssh root@45.144.64.218 -p 2200
|
||||
```
|
||||
|
||||
### 1.1. Добавление репозитория HashiCorp
|
||||
|
||||
1. Установите необходимые пакеты:
|
||||
```sh
|
||||
sudo apt update && sudo apt install -y gnupg software-properties-common curl
|
||||
```
|
||||
|
||||
2. Добавьте официальный GPG-ключ HashiCorp:
|
||||
```sh
|
||||
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
||||
```
|
||||
|
||||
3. Добавьте репозиторий HashiCorp в систему:
|
||||
```sh
|
||||
sudo mcedit /etc/apt/sources.list.d/hashicorp.list
|
||||
```
|
||||
|
||||
Заменяем на:
|
||||
```text
|
||||
deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com noble main
|
||||
```
|
||||
Где noble это кодовое имя Ubuntu 24.04
|
||||
|
||||
|
||||
4. Обновите списки пакетов:
|
||||
```sh
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
5. Установите Vault:
|
||||
```sh
|
||||
sudo apt install -y vault
|
||||
```
|
||||
|
||||
6. Проверьте, что Vault установлен правильно:
|
||||
```sh
|
||||
vault --version
|
||||
```
|
||||
Выдало: Vault v1.18.5 (2cb3755273dbd63f5b0f8ec50089b57ffd3fa330), built 2025-02-24T09:40:28Z
|
||||
|
||||
|
||||
## 2. Запуск Vault
|
||||
|
||||
### 2.1. Запуск в Dev-режиме (только для тестирования)
|
||||
|
||||
If work stop it:
|
||||
```sh
|
||||
sudo pkill vault
|
||||
```
|
||||
If need delete old data:
|
||||
```sh
|
||||
sudo rm -rf ~/.vault-token ~/.vault/
|
||||
```
|
||||
For find where stored data read file:
|
||||
```sh
|
||||
sudo mcedit /etc/vault/config.hcl
|
||||
```
|
||||
In config file find this path: /opt/vault/data
|
||||
|
||||
После удаления базы нужно инициализировать Vault заново:
|
||||
```sh
|
||||
sudo vault operator init
|
||||
```
|
||||
|
||||
Run in developer mode (in dev mode data stored in RAM):
|
||||
```sh
|
||||
vault server -dev
|
||||
```
|
||||
|
||||
```text
|
||||
WARNING! dev mode is enabled! In this mode, Vault runs entirely in-memory
|
||||
and starts unsealed with a single unseal key. The root token is already
|
||||
authenticated to the CLI, so you can immediately begin using Vault.
|
||||
|
||||
You may need to set the following environment variables:
|
||||
|
||||
$ export VAULT_ADDR='http://127.0.0.1:8200'
|
||||
|
||||
The unseal key and root token are displayed below in case you want to
|
||||
seal/unseal the Vault or re-authenticate.
|
||||
|
||||
Unseal Key: TMb6A3QI3wJ9kaEeTYo5wEviP23lugJ3Asek2la6V4s=
|
||||
Root Token: hvs.GsWHRR7ne7gMTZhuPgZdh91w
|
||||
|
||||
Development mode should NOT be used in production installations!
|
||||
```
|
||||
|
||||
Теперь Vault работает по адресу:
|
||||
```sh
|
||||
start http://127.0.0.1:8200
|
||||
```
|
||||
Останавливаю нажатием Ctrl + C
|
||||
|
||||
|
||||
### 2.2. Настройка Vault в режиме сервера
|
||||
|
||||
1. Создайте конфигурационный файл:
|
||||
```sh
|
||||
sudo mkdir -p /etc/vault &&
|
||||
sudo mcedit /etc/vault/config.hcl
|
||||
```
|
||||
|
||||
2. Добавьте следующий конфиг:
|
||||
```text
|
||||
storage "file" {
|
||||
path = "/opt/vault/data"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "127.0.0.1:8200"
|
||||
tls_disable = 1
|
||||
}
|
||||
|
||||
disable_mlock = true
|
||||
ui = true
|
||||
```
|
||||
|
||||
3. Создайте папку для хранения данных:
|
||||
```sh
|
||||
sudo mkdir -p /opt/vault/data &&
|
||||
sudo chown vault:vault /opt/vault/data
|
||||
```
|
||||
|
||||
4. Создайте systemd-сервис для Vault:
|
||||
```sh
|
||||
sudo tee /etc/systemd/system/vault.service > /dev/null <<'EOF'
|
||||
[Unit]
|
||||
Description=HashiCorp Vault
|
||||
After=network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
User=vault
|
||||
Group=vault
|
||||
ExecStart=/usr/bin/vault server -config=/etc/vault/config.hcl
|
||||
ExecReload=/bin/kill --signal HUP \$MAINPID
|
||||
KillSignal=SIGTERM
|
||||
Restart=on-failure
|
||||
LimitMEMLOCK=infinity
|
||||
ProtectSystem=full
|
||||
CapabilityBoundingSet=CAP_IPC_LOCK CAP_SETGID CAP_SETUID CAP_SYSLOG CAP_CHOWN
|
||||
NoNewPrivileges=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
```
|
||||
Проверяем всё ли записалось:
|
||||
```sh
|
||||
sudo mcedit /etc/systemd/system/vault.service
|
||||
```
|
||||
|
||||
5. Перезапустите systemd и включите Vault:
|
||||
```sh
|
||||
sudo systemctl daemon-reload &&
|
||||
sudo systemctl enable vault &&
|
||||
sudo systemctl start vault
|
||||
```
|
||||
|
||||
7. Проверьте статус:
|
||||
```sh
|
||||
sudo systemctl status vault
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Инициализация и разлочка Vault
|
||||
|
||||
1. Экспортируйте переменную окружения:
|
||||
```sh
|
||||
export VAULT_ADDR='http://127.0.0.1:8200'
|
||||
```
|
||||
|
||||
2. Инициализируйте хранилище (сохраните ключи!):
|
||||
```sh
|
||||
vault operator init
|
||||
```
|
||||
|
||||
Выдало:
|
||||
```text
|
||||
Unseal Key 1: lQlJsb9RI8rSzLrc5iPnx1qJkWZbbXIkrEgnQGe5R6uO
|
||||
Unseal Key 2: 0qJJXRo570jlH/0Qs/wodXHNI2SF5VgL4jE04JawSPSB
|
||||
Unseal Key 3: VuYkOkQ8qmwofDmjqsTRQoMqGAH3Jv+nqQylL7Uibbtp
|
||||
Unseal Key 4: JJJ8Nqj00qzS9u5wNtTtExL/jWlJF9fgaBsiuaf0kFxC
|
||||
Unseal Key 5: L6lZMp/l7s24EZJAFnWS4Py5jsWOuMioC41g5LhUJKWL
|
||||
|
||||
Initial Root Token: hvs.o07DY7tnSPcufxk60pjCXDzn
|
||||
|
||||
Vault initialized with 5 key shares and a key threshold of 3. Please securely
|
||||
distribute the key shares printed above. When the Vault is re-sealed,
|
||||
restarted, or stopped, you must supply at least 3 of these keys to unseal it
|
||||
before it can start servicing requests.
|
||||
|
||||
Vault does not store the generated root key. Without at least 3 keys to
|
||||
reconstruct the root key, Vault will remain permanently sealed!
|
||||
|
||||
It is possible to generate new unseal keys, provided you have a quorum of
|
||||
existing unseal keys shares. See "vault operator rekey" for more information.
|
||||
```
|
||||
|
||||
3. Разблокируйте Vault, используя один из ключей (потом ещё 3 раза выполнить эту команду):
|
||||
```sh
|
||||
vault operator unseal
|
||||
```
|
||||
|
||||
4. Авторизуйтесь с root-токеном:
|
||||
```sh
|
||||
vault login hvs.MTFV72PjKXCVh5ZL6yCVE3Yw
|
||||
```
|
||||
|
||||
5. Создаём(включаем) новое хранилище ключ-значение через ssh
|
||||
```sh
|
||||
vault secrets enable -path=org-ccalm kv-v2
|
||||
```
|
||||
|
||||
|
||||
|
||||
5. Writing to the kv storage (добавил префикс vault. чтобы значения самому подставлять в нужные места в spring)
|
||||
|
||||
Заменит(создаст) значение:
|
||||
```sh
|
||||
vault kv put org-ccalm/jwt vault.server.ssl.key-store-password=MFNX344yh4
|
||||
```
|
||||
Добавит (обновит):
|
||||
```sh
|
||||
vault kv patch org-ccalm/jwt vault.test=test2
|
||||
```
|
||||
```sh
|
||||
vault kv put org-ccalm/public vault.personal_data.key=7dd2Nek1
|
||||
```
|
||||
|
||||
6. Read data from the kv
|
||||
```sh
|
||||
vault kv get org-ccalm/jwt
|
||||
```
|
||||
|
||||
Должно вывести:
|
||||
```text
|
||||
Key Value
|
||||
--- -----
|
||||
server.ssl.key-store-password M4yh4
|
||||
```
|
||||
|
||||
6. Включаем AppRole для доступа из приложения
|
||||
```sh
|
||||
vault auth enable approle
|
||||
```
|
||||
|
||||
7. Добавляем политики потом создаём ключ для этой политикиполитики
|
||||
|
||||
Создаю файл политик
|
||||
```sh
|
||||
cd ~ &&
|
||||
sudo tee jwt-policy.hcl > /dev/null <<'EOF'
|
||||
path "org-ccalm/data/jwt" {
|
||||
capabilities = ["create", "read", "update", "delete", "list"]
|
||||
}
|
||||
path "org-ccalm/data/public" {
|
||||
capabilities = ["read", "list"]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
Apply and delete configiration file:
|
||||
```sh
|
||||
vault policy write jwt-policy ~/jwt-policy.hcl &&
|
||||
rm -f jwt-policy.hcl
|
||||
```
|
||||
|
||||
Создаём AppRole (на 10 лет)
|
||||
```sh
|
||||
vault write auth/approle/role/org-ccalm-jwt \
|
||||
secret_id_ttl=0 \
|
||||
token_ttl=87600h \
|
||||
token_max_ttl=87600h \
|
||||
policies="jwt-policy,another-policy,third-policy"
|
||||
```
|
||||
|
||||
Получаем role_id и secret_id
|
||||
```sh
|
||||
vault read auth/approle/role/org-ccalm-jwt/role-id
|
||||
```
|
||||
Выдало
|
||||
```text
|
||||
Key Value
|
||||
--- -----
|
||||
role_id c0064fe2-8f0e-b317-7fe7-66f7405b45a1
|
||||
```
|
||||
На команду
|
||||
```sh
|
||||
vault write -f auth/approle/role/org-ccalm-jwt/secret-id
|
||||
```
|
||||
Выдало:
|
||||
```text
|
||||
Key Value
|
||||
--- -----
|
||||
secret_id 24f31c88-7185-0d93-9a51-e221c2925265
|
||||
secret_id_accessor 22fa68e3-fc73-2008-0a34-3506630b6693
|
||||
secret_id_num_uses 0
|
||||
secret_id_ttl 0s
|
||||
```
|
||||
Сохрани role_id и secret_id, они понадобятся Spring Boot.
|
||||
|
||||
Хранить ключи лучьше в переменных окружения
|
||||
```sh
|
||||
export VAULT_ROLE_ID="your-role-id" &&
|
||||
export VAULT_SECRET_ID="your-secret-id"
|
||||
```
|
||||
|
||||
|
||||
Проверяем не больше какого значения можно задать время жизни кокена:
|
||||
```sh
|
||||
vault read sys/mounts/auth/token/tune
|
||||
```
|
||||
По умолчанию max_lease_ttl равен 32 дня!
|
||||
|
||||
На год можно увеличить так:
|
||||
```sh
|
||||
vault write sys/mounts/auth/token/tune max_lease_ttl=8760h
|
||||
```
|
||||
|
||||
Create data access token with set politics:
|
||||
```sh
|
||||
vault token create -policy=jwt-policy -ttl=0
|
||||
```
|
||||
|
||||
Продлевать токен можно так:
|
||||
```sh
|
||||
vault token renew <твой-токен>
|
||||
```
|
||||
|
||||
Проверяем зранятся ли токены в хранилище а не в памяти
|
||||
```sh
|
||||
vault read sys/auth/token/tune
|
||||
```
|
||||
token_type = default-service, значит Vault не хранит токены
|
||||
|
||||
Включаем хранение токенов:
|
||||
```sh
|
||||
vault write sys/auth/token/tune token_type=service
|
||||
```
|
||||
|
||||
|
||||
|
||||
---
|
||||
Теперь HashiCorp Vault установлен и готов к использованию! 🚀
|
||||
|
||||
@ -1,136 +1,136 @@
|
||||
|
||||
Загрузить в HashiCorp Vault настройки можно так:
|
||||
|
||||
```sh
|
||||
vault kv put secret/org-ccalm-jwt \
|
||||
jwt.secret=my-secret-value \
|
||||
db.user=admin \
|
||||
db.pass=123456
|
||||
```
|
||||
|
||||
Разбор параметров:
|
||||
1. vault kv put – команда для записи ключей и значений в KV-хранилище Vault.
|
||||
2. secret/org-ccalm-jwt – путь к секрету.
|
||||
* secret/ – это backend-хранилище (оно должно быть включено в Vault).
|
||||
* org-ccalm-jwt – имя секрета, под которым сохраняются параметры.
|
||||
3. jwt.secret=my-secret-value – ключ jwt.secret со значением my-secret-value.
|
||||
4. db.user=admin – ключ db.user со значением admin.
|
||||
5. db.pass=123456 – ключ db.pass со значением 123456.
|
||||
|
||||
|
||||
# 🚀 Установка и настройка HashiCorp Vault на Windows
|
||||
|
||||
## 📌 1. Установка HashiCorp Vault
|
||||
|
||||
1. **Скачайте Vault CLI** с официального сайта:
|
||||
🔗 [https://developer.hashicorp.com/vault/downloads](https://developer.hashicorp.com/vault/downloads)
|
||||
2. Распакуйте архив и **добавьте путь к `vault.exe` в `PATH`**:
|
||||
- Кликните **ПКМ → Этот компьютер → Свойства → Дополнительные параметры системы**.
|
||||
- В **Переменные среды** добавьте путь к папке с `vault.exe`.
|
||||
3. Откройте **cmd** или **PowerShell** и проверьте установку командой:
|
||||
```sh
|
||||
vault --version
|
||||
```
|
||||
Если всё ОК, увидите версию Vault. Примерно такую: Vault v1.18.4 (503be623a3697e8c10c254dc87d26492c46753e1), built 2025-01-29T13:57:54Z
|
||||
|
||||
---
|
||||
|
||||
## 📌 2. Запуск Vault-сервера (разработческий режим)
|
||||
|
||||
Чтобы локально запустить Vault в **dev-режиме** (без авторизации), выполните:
|
||||
```sh
|
||||
vault server -dev
|
||||
```
|
||||
После запуска он покажет **root-токен** (сохраните его!):
|
||||
```plaintext
|
||||
Unseal Key: x1jUXpLJREI6M1+Qm6m/h3NLEhaEmBageqw0v+dSSKo=
|
||||
Root Token: hvs.V7Rc8uJ8YJ0AASKZfep6oYNe
|
||||
```
|
||||
|
||||
Теперь Vault работает по адресу:
|
||||
```sh
|
||||
start http://127.0.0.1:8200
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📌 3. Экспорт токена (чтобы не вводить каждый раз)
|
||||
|
||||
Откройте **PowerShell** и выполните:
|
||||
```sh
|
||||
$env:VAULT_ADDR="http://127.0.0.1:8200"
|
||||
$env:VAULT_TOKEN="hvs.JDIyKgDMagA0WyIhLFQ4mAjZ"
|
||||
```
|
||||
(Замените `hvs.JDIyKgDMagA0WyIhLFQ4mAjZ` на свой токен.)
|
||||
|
||||
Теперь можно работать с Vault без ввода токена каждый раз.
|
||||
|
||||
---
|
||||
|
||||
## 📌 4. Запись значений в Vault на Windows
|
||||
|
||||
Значения разделенные пробелами можно записать в вольт так:
|
||||
```sh
|
||||
vault kv put secret/kz-istransit-jwt server.ssl.key-store-password=MFNX344yh4
|
||||
```
|
||||
Выдаст примерно такое:
|
||||
======== Secret Path ========
|
||||
secret/data/kz-istransit-jwt
|
||||
|
||||
======= Metadata =======
|
||||
Key Value
|
||||
--- -----
|
||||
created_time 2025-02-24T12:49:45.7630328Z
|
||||
custom_metadata <nil>
|
||||
deletion_time n/a
|
||||
destroyed false
|
||||
version 1
|
||||
|
||||
---
|
||||
|
||||
## 📌 5. Проверка сохранённых данных
|
||||
|
||||
Чтобы посмотреть, что записано в Vault:
|
||||
```sh
|
||||
vault kv get secret/kz-istransit-jwt
|
||||
```
|
||||
Если всё настроено правильно, вы увидите примерно такой вывод:
|
||||
```plaintext
|
||||
====== Metadata ======
|
||||
Key Value
|
||||
--- -----
|
||||
created_time 2025-02-24T12:00:00Z
|
||||
version 1
|
||||
|
||||
====== Data ======
|
||||
Key Value
|
||||
--- -----
|
||||
db.pass 123456
|
||||
db.user admin
|
||||
jwt.secret my-secret-value
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📌 6. Удаление данных из Vault
|
||||
|
||||
Удаление данных:
|
||||
```sh
|
||||
vault kv delete secret/org-ccalm-jwt
|
||||
```
|
||||
Полное уничтожение (без возможности восстановления):
|
||||
```sh
|
||||
vault kv destroy -versions=1 secret/org-ccalm-jwt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Итог
|
||||
✅ Установили Vault CLI
|
||||
✅ Запустили Vault сервер (`vault server -dev`)
|
||||
✅ Экспортировали `VAULT_ADDR` и `VAULT_TOKEN`
|
||||
✅ Записали настройки в Vault
|
||||
✅ Проверили данные
|
||||
|
||||
Теперь можно интегрировать Vault в Spring Boot 🚀
|
||||
|
||||
|
||||
Загрузить в HashiCorp Vault настройки можно так:
|
||||
|
||||
```sh
|
||||
vault kv put secret/org-ccalm-jwt \
|
||||
jwt.secret=my-secret-value \
|
||||
db.user=admin \
|
||||
db.pass=123456
|
||||
```
|
||||
|
||||
Разбор параметров:
|
||||
1. vault kv put – команда для записи ключей и значений в KV-хранилище Vault.
|
||||
2. secret/org-ccalm-jwt – путь к секрету.
|
||||
* secret/ – это backend-хранилище (оно должно быть включено в Vault).
|
||||
* org-ccalm-jwt – имя секрета, под которым сохраняются параметры.
|
||||
3. jwt.secret=my-secret-value – ключ jwt.secret со значением my-secret-value.
|
||||
4. db.user=admin – ключ db.user со значением admin.
|
||||
5. db.pass=123456 – ключ db.pass со значением 123456.
|
||||
|
||||
|
||||
# 🚀 Установка и настройка HashiCorp Vault на Windows
|
||||
|
||||
## 📌 1. Установка HashiCorp Vault
|
||||
|
||||
1. **Скачайте Vault CLI** с официального сайта:
|
||||
🔗 [https://developer.hashicorp.com/vault/downloads](https://developer.hashicorp.com/vault/downloads)
|
||||
2. Распакуйте архив и **добавьте путь к `vault.exe` в `PATH`**:
|
||||
- Кликните **ПКМ → Этот компьютер → Свойства → Дополнительные параметры системы**.
|
||||
- В **Переменные среды** добавьте путь к папке с `vault.exe`.
|
||||
3. Откройте **cmd** или **PowerShell** и проверьте установку командой:
|
||||
```sh
|
||||
vault --version
|
||||
```
|
||||
Если всё ОК, увидите версию Vault. Примерно такую: Vault v1.18.4 (503be623a3697e8c10c254dc87d26492c46753e1), built 2025-01-29T13:57:54Z
|
||||
|
||||
---
|
||||
|
||||
## 📌 2. Запуск Vault-сервера (разработческий режим)
|
||||
|
||||
Чтобы локально запустить Vault в **dev-режиме** (без авторизации), выполните:
|
||||
```sh
|
||||
vault server -dev
|
||||
```
|
||||
После запуска он покажет **root-токен** (сохраните его!):
|
||||
```plaintext
|
||||
Unseal Key: x1jUXpLJREI6M1+Qm6m/h3NLEhaEmBageqw0v+dSSKo=
|
||||
Root Token: hvs.V7Rc8uJ8YJ0AASKZfep6oYNe
|
||||
```
|
||||
|
||||
Теперь Vault работает по адресу:
|
||||
```sh
|
||||
start http://127.0.0.1:8200
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📌 3. Экспорт токена (чтобы не вводить каждый раз)
|
||||
|
||||
Откройте **PowerShell** и выполните:
|
||||
```sh
|
||||
$env:VAULT_ADDR="http://127.0.0.1:8200"
|
||||
$env:VAULT_TOKEN="hvs.JDIyKgDMagA0WyIhLFQ4mAjZ"
|
||||
```
|
||||
(Замените `hvs.JDIyKgDMagA0WyIhLFQ4mAjZ` на свой токен.)
|
||||
|
||||
Теперь можно работать с Vault без ввода токена каждый раз.
|
||||
|
||||
---
|
||||
|
||||
## 📌 4. Запись значений в Vault на Windows
|
||||
|
||||
Значения разделенные пробелами можно записать в вольт так:
|
||||
```sh
|
||||
vault kv put secret/kz-istransit-jwt server.ssl.key-store-password=MFNX344yh4
|
||||
```
|
||||
Выдаст примерно такое:
|
||||
======== Secret Path ========
|
||||
secret/data/kz-istransit-jwt
|
||||
|
||||
======= Metadata =======
|
||||
Key Value
|
||||
--- -----
|
||||
created_time 2025-02-24T12:49:45.7630328Z
|
||||
custom_metadata <nil>
|
||||
deletion_time n/a
|
||||
destroyed false
|
||||
version 1
|
||||
|
||||
---
|
||||
|
||||
## 📌 5. Проверка сохранённых данных
|
||||
|
||||
Чтобы посмотреть, что записано в Vault:
|
||||
```sh
|
||||
vault kv get secret/kz-istransit-jwt
|
||||
```
|
||||
Если всё настроено правильно, вы увидите примерно такой вывод:
|
||||
```plaintext
|
||||
====== Metadata ======
|
||||
Key Value
|
||||
--- -----
|
||||
created_time 2025-02-24T12:00:00Z
|
||||
version 1
|
||||
|
||||
====== Data ======
|
||||
Key Value
|
||||
--- -----
|
||||
db.pass 123456
|
||||
db.user admin
|
||||
jwt.secret my-secret-value
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📌 6. Удаление данных из Vault
|
||||
|
||||
Удаление данных:
|
||||
```sh
|
||||
vault kv delete secret/org-ccalm-jwt
|
||||
```
|
||||
Полное уничтожение (без возможности восстановления):
|
||||
```sh
|
||||
vault kv destroy -versions=1 secret/org-ccalm-jwt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Итог
|
||||
✅ Установили Vault CLI
|
||||
✅ Запустили Vault сервер (`vault server -dev`)
|
||||
✅ Экспортировали `VAULT_ADDR` и `VAULT_TOKEN`
|
||||
✅ Записали настройки в Vault
|
||||
✅ Проверили данные
|
||||
|
||||
Теперь можно интегрировать Vault в Spring Boot 🚀
|
||||
|
||||
Reference in New Issue
Block a user