This commit is contained in:
sotos
2025-12-08 09:45:23 +01:00
parent 508f1a46b2
commit 4e92a6d6f3
8 changed files with 31 additions and 58 deletions

View File

View File

@@ -4,39 +4,29 @@ services:
image: prom/prometheus:latest image: prom/prometheus:latest
volumes: volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
ports: ports:
- "9090:9090" - "9090:9090"
networks: networks:
- webnet - snake_net
restart: unless-stopped restart: unless-stopped
grafana: grafana:
image: grafana/grafana:9.0.0 image: grafana/grafana:latest
user: "472" user: "472"
volumes: volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro - ./grafana/provisioning:/etc/grafana/provisioning:ro
- grafana_data:/var/lib/grafana
environment: environment:
GF_SECURITY_ADMIN_PASSWORD: "admin" GF_SECURITY_ADMIN_PASSWORD: "admin"
ports: ports:
- "3000:3000" - "3000:3000"
networks: networks:
- webnet - snake_net
restart: unless-stopped
nginx_exporter:
image: nginx/nginx-prometheus-exporter:0.9.0
environment:
SCRAPE_URI: http://snake:80/nginx_status
networks:
- webnet
restart: unless-stopped restart: unless-stopped
volumes: volumes:
prometheus_data:
grafana_data: grafana_data:
networks: networks:
webnet: snake_net:
external: true external: true

View File

@@ -0,0 +1,7 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'snake_nginx'
static_configs:
- targets: ['213.95.90.157:81']

View File

@@ -1,22 +1,9 @@
FROM alpine:latest FROM nginx:stable-alpine
RUN apk add --no-cache nginx bash curl php82 php82-fpm php82-mysqli \ # Copy Snake game HTML
php82-pdo php82-pdo_mysql php82-gd php82-opcache php82-session \ COPY index.html /usr/share/nginx/html/index.html
php82-ctype php82-dom php82-mbstring php82-zlib php82-curl tar
# Verzeichnisse anlegen und Rechte setzen # Copy custom Nginx config with stub_status
RUN mkdir -p /run/nginx /var/log/nginx /var/www/html /data \
&& chmod o+rx /data \
&& chmod -R o+r /data \
&& rm -rf /var/www/html \
&& ln -s /data /var/www/html \
&& chown -R 101:101 /data
# nginx config und Startskript kopieren
COPY nginx.conf /etc/nginx/nginx.conf COPY nginx.conf /etc/nginx/nginx.conf
COPY start.sh /start.sh
RUN chmod +x /start.sh
EXPOSE 80 EXPOSE 80 81
CMD ["/start.sh"]

View File

@@ -1,40 +1,29 @@
worker_processes auto; worker_processes 1;
events { worker_connections 1024; }
events {
worker_connections 1024;
}
http { http {
include mime.types; include mime.types;
default_type application/octet-stream; default_type application/octet-stream;
sendfile on; # Snake game server
keepalive_timeout 65;
client_max_body_size 100M;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server { server {
listen 80; listen 80;
server_name localhost; server_name _;
root /var/www/html;
index index.php index.html index.htm;
location / { location / {
try_files $uri $uri/ /index.php?$args; root /usr/share/nginx/html;
index index.html;
} }
}
location ~ \.php$ { # Metrics for Prometheus
fastcgi_split_path_info ^(.+\.php)(/.+)$; server {
fastcgi_pass 127.0.0.1:9000; listen 81;
fastcgi_index index.php; server_name _;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht { location /nginx_status {
stub_status;
allow 0.0.0.0/0; # adjust for security; or restrict to your Prometheus server
deny all; deny all;
} }
} }