Skip to content

Commit 1e59933

Browse files
committed
fix: solve filebeat issue
1 parent d641764 commit 1e59933

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ INTERNAL_JWT_SECRET=
113113
# ===========================================
114114
# Sidekiq Web UI (production access)
115115
# ===========================================
116-
# Password for /sidekiq dashboard. Protected by HTTP Basic Auth (user: prostaff).
117-
# Leave blank to keep the UI inaccessible (safe default).
118-
# Set a strong random value in production (e.g. openssl rand -hex 32).
116+
# Credentials for /sidekiq dashboard (HTTP Basic Auth).
117+
# Both must be set — UI stays inaccessible if either is blank (safe default).
118+
# Generate password: openssl rand -hex 32
119+
SIDEKIQ_WEB_USER=
119120
SIDEKIQ_WEB_PASSWORD=
120121

121122
# ===========================================

config/routes.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,18 @@
502502

503503
require 'sidekiq/web'
504504
Sidekiq::Web.use(Rack::Auth::Basic) do |user, password|
505-
user == 'prostaff' && ActiveSupport::SecurityUtils.secure_compare(
505+
expected_user = ENV.fetch('SIDEKIQ_WEB_USER', nil)
506+
expected_password = ENV.fetch('SIDEKIQ_WEB_PASSWORD', nil)
507+
508+
next false if expected_user.blank? || expected_password.blank?
509+
510+
user_match = ActiveSupport::SecurityUtils.secure_compare(user, expected_user)
511+
password_match = ActiveSupport::SecurityUtils.secure_compare(
506512
::Digest::SHA256.hexdigest(password),
507-
::Digest::SHA256.hexdigest(ENV.fetch('SIDEKIQ_WEB_PASSWORD', ''))
513+
::Digest::SHA256.hexdigest(expected_password)
508514
)
515+
516+
user_match && password_match
509517
end
510518
mount Sidekiq::Web => '/sidekiq'
511519
end

infra/filebeat/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
filebeat:
33
image: docker.elastic.co/beats/filebeat:8.19.0
4-
user: root
4+
user: root # required to read /var/lib/docker/containers (owned by root on host)
55
restart: unless-stopped
66
volumes:
77
- /var/lib/docker/containers:/var/lib/docker/containers:ro

infra/filebeat/filebeat.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ filebeat.autodiscover:
1010
- type: container
1111
paths:
1212
- /var/lib/docker/containers/${data.docker.container.id}/*.log
13-
json.keys_under_root: false
13+
json.keys_under_root: true
14+
json.overwrite_keys: true
15+
json.add_error_key: true
1416
fields:
1517
service: api
1618
- condition:

0 commit comments

Comments
 (0)