Skip to content

Commit

Permalink
Change nginx logs to json
Browse files Browse the repository at this point in the history
  • Loading branch information
Tackx committed Mar 31, 2024
1 parent 0ec9cf5 commit e88ddee
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
34 changes: 16 additions & 18 deletions .docker/nginx-default.conf
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
server {
listen 80;
server_name helldivehelper.net www.helldivehelper.net;
server {
listen 80;
server_name helldivehelper.net www.helldivehelper.net;

# access_log /var/log/nginx/host.access.log main;
root /var/www/html;
index index.html index.htm;

root /var/www/html;
index index.html index.htm;
location / {
try_files $uri /index.html;
}

location / {
try_files $uri /index.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}



# http {
# log_format main escape=json '{"source": "nginx", "time": $msec, "resp_body_size": $body_bytes_sent, "host": "$http_host", "address": "$remote_addr", "request_length": $request_length, "method": "$request_method", "uri": "$request_uri", "status": $status, "user_agent": "$http_user_agent", "resp_time": $request_time, "upstream_addr": "$upstream_addr"}';
# }
29 changes: 29 additions & 0 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main escape=json '{"source": "nginx", "time": $msec, "resp_body_size": $body_bytes_sent, "host": "$http_host", "address": "$remote_addr", "request_length": $request_length, "method": "$request_method", "uri": "$request_uri", "status": $status, "user_agent": "$http_user_agent", "resp_time": $request_time, "upstream_addr": "$upstream_addr"}';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
- NODE_ENV
volumes:
- "helldive-helper-data:/opt/${APP_NAME}"
- .docker/nginx.conf:/etc/nginx/nginx.conf
- .docker/nginx-default.conf:/etc/nginx/conf.d/default.conf
cpus: 1.5
dns:
Expand Down

0 comments on commit e88ddee

Please sign in to comment.