Closed KonradHoeffner closed 8 months ago
There are two config files at play here:
/etc/nginx/nginx.conf
is the default configuration and contains configuration of the nginx server.
nginx.conf
from the base path of this repository contains configuration of the specific web app and is copied into the /etc/nginx/conf.d/
directory, which is included from a statement of /etc/nginx/nginx.conf
: include /etc/nginx/conf.d/*.conf;
.
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 '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
I don't know if it is possible and a better solution to merge those two or if overriding the error_log statement from within the nginx.conf from this repository works as I already tried overwriting it using an env variable which didn't work, so I am not sure if the changes are worth it to try that but feel free if you want. I agree that the current way sucks because there are two different files with the same name but I'm not sure if there is a more elegant way.
server {
listen 80 default_server;
root /usr/share/nginx/html;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html;
charset utf-8;
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
location = /favicon.ico {
access_log off;
log_not_found off;
}
location = /robots.txt {
access_log off;
log_not_found off;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
The Nginx documentation is a bit confusing here.
The default setting of the error log works globally. To override it, place the error_log directive in the main (top-level) configuration context.
However, if several error_log directives are specified on the same level, the message are written to all specified logs.
I am not sure if error_log
can be overridden (maybe the top level is an exception?). I will try it tomorrow and if it works, I will create another PR.
I am not sure if
error_log
can be overridden (maybe the top level is an exception?). I will try it tomorrow and if it works, I will create another PR.
Good luck! Maybe this StackOverflow post can help you: https://unix.stackexchange.com/questions/769346/how-to-suppress-nginx-worker-process-notices/771151#771151 at least that shows what I tried to overwrite it which didn't work :-)
P.S.: Or we just switch to Caddy :-)
P.S.: Or we just switch to Caddy :-)
As discussed recently, this would be a nice (or even better) option. But I lack the Caddy knowledge.
Part of https://github.com/Onto-Med/top-deployment/issues/44.