mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-04-25 17:35:52 +03:00
[GH-ISSUE #714] log_format in advanced tab not working #605
Labels
No labels
awaiting feedback
bug
cannot reproduce
dns provider request
duplicate
enhancement
enhancement
enhancement
good first issue
help wanted
invalid
need more info
no certbot plugin available
product-support
pull-request
question
stale
troll
upstream issue
v2
v2
v2
v3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-proxy-manager-NginxProxyManager#605
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Treppengelaender on GitHub (Nov 11, 2020).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/714
I want to add a Custom Nginx Configuration to my Proxy Host.
I've added the command
access_log /path/to/logfile.log proxy;
with success.
But now i want to change the output of the logfile.
I thought it is as easy as declare a new log_format into the Custom Configuration Window.
But when i try to add something like
log_format custom '$remote_addr - $remote_user';
the Status from this Proxy Hosts toggles from Online to Offline.
Is there a good solution to customize the log_format? Is it just a bug and it shoult be in general possible to edit the log_format in the Custom Nginx Configuration Window?
Best Regards
@Highview-Lucas commented on GitHub (Nov 16, 2020):
the project sets it's own log file format for some reason.
It would be nice to have the option of selecting one of the standard (apache/nginx/etc) ones, or overriding it entirely.
@wasn-eu commented on GitHub (Nov 17, 2020):
I go with that
To use the standard analyzer tools we need the standard log format
@tuxmeister commented on GitHub (Nov 19, 2020):
I honestly can't find a good reason for this project to have a non-standard log format by default. I've been fighting with telegraf and grok patterns (new stuff to me) for the better part of the afternoon just to get some metrics into Influx... just... why? I can't even find the source place where this is defined to change it before the container is configured.
@jc21 would adding the custom output format in one of the "advanced config" file appenders work?
EDIT: just to clarify, I have not been successful with grok, even though I'm using a constructor to help me, I still find that for most of my proxy hosts, the cache status is a dash so I can't make one pattern to rule them all (within my ability and patience right now).
@Highview-Lucas commented on GitHub (Nov 20, 2020):
the log_format definitions need to go into the base nginx.conf, the actual logging line can just go into the host definition. (so you can't just put it into the custom configuration inside the webUI, as you've discovered)
/etc/nginx/nginx.conf inside the docker container has log_format entries on lines 46/47
You can comment out these two lines and put in standard ("combined") log_format definitions - i don't have them handy, I'm at work, nginx docs should have the standard ones though!
make sure you name them correctly, the lines will need to start with "log_format proxy" and "log_format standard"
this does leave us an opening to define log_formats and then select which one we want per host inside the WebUI (and by "we" i mean someone else ;) )
@Treppengelaender commented on GitHub (Nov 20, 2020):
Yes, editing /etc/nginx/nginx.conf works. It is also possible to add a line log_format customtemplate 'YOUROPTIONSHERE';
But wouldn't updating the container destroy changes made in /etc/nginx/nginx.conf?
Is there a way to change the log_format or set a custom log_format in the /data directory in the container?
@Highview-Lucas commented on GitHub (Nov 26, 2020):
I think I ended up putting /etc/nginx into a bind-mounted directory - changes persist through recreations - but if there's a huge change, it's likely to bite me.
@d33pjs commented on GitHub (May 1, 2021):
Upvote this feature. Did anyone got that working with advanced configurations?
@chaptergy commented on GitHub (May 12, 2021):
You could open a PR with this change (removing the
log_formatfromnginx.conf) and explaining your reasons. Removing the two lines is not much effort. The worst thing that could happen is that he rejects it and you have wasted 5 minutes of your time.@PathToLife commented on GitHub (Jun 2, 2021):
You can specify a custom log_format by creating a file in
/data/nginx/custom/http_top.confthen restarting the server.
whatever is inside there is injected directly into
http {}of nginx.conf https://github.com/jc21/nginx-proxy-manager/blob/master/docker/rootfs/etc/nginx/nginx.confexample below i added real-ip
[Real-ip $http_cf_connecting_ip]then added in the dashboard
access_log /data/logs/proxy2_host-7.log proxy2;note
log_format standardlog_format proxyare already defined nginx does not let you override them@d33pjs commented on GitHub (Jun 4, 2021):
This worked perfectly. Thank you so much!
@AMWN commented on GitHub (Oct 25, 2021):
Made a regexp for the custom proxy log_format. It's not perfect, but works for me for scraping with Promtail.
\[(?P<dateandtime>\d{2}\/[A-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] (?P<upstream_cache_status>-) (?P<upstream_status>[^ ]*) (?P<status>[^ ]*) - (?P<request_method>[\w\.]+) (?P<scheme>[\w\.]+) (?P<host>[^"]*) "(?P<request_uri>[^"]*)" \[Client (?P<remote_addr>[\w\.]+)\] \[Length (?P<bytessent>\d+)\] \[Gzip (?P<gzip_ratio>[^ ])\] \[Sent-to (?P<Sentto>[^"]*)\] "(?P<http_user_agent>[^"]*)" "(?P<http_referer>[^"]*)"@TehloWasTaken commented on GitHub (Mar 3, 2022):
Hey, thanks for posting this. I just tried doing this but it isn't working properly and it isn't reading my config file to apply the custom log format. Could you maybe help me out?
I am trying to use the log format from this link:
https://grafana.com/grafana/dashboards/12559
I applied it in the http_top.conf in the proper folder, but it just isn't reading it and still applying the standard format. Help?
@motionrus commented on GitHub (Jan 12, 2023):
My
data/nginx/proxy_host/1.conffile now duplicates the logsIf I look at the
proxy-host-1_access.logfile, I see duplicationHere is my
data/nginx/custom/http_top.confDoes anyone know how to solve the problem with duplication?
@okworx commented on GitHub (Jan 21, 2023):
Here's a regex that works for import into Matomo together with
--log-date-format='%d/%b/%Y:%H:%M:%S %z':'\[(?P<date>\d{2}\/[A-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2}\s+(\+|\-)\d{4})\]\s+(?P<upstream_cache_status>-)\s+(?P<upstream_status>[^ ]*)\s+(?P<status>[^ ]*)\s+-\s+(?P<request_method>[\w\.]+)\s+(?P<scheme>[\w\.]+)\s+(?P<host>[^"]*)\s+"(?P<path>[^"]*)"\s+\[Client (?P<ip>[\w\.]+)\]\s+\[Length (?P<bytessent>\d+)\]\s+\[Gzip\s+(?P<gzip_ratio>[\d\.\-]+)\]\s+\[Sent-to (?P<Sentto>[^"]*)\]\s+"(?P<user_agent>[^"]*)"\s+"(?P<referrer>[^"]*)"'@hoseinmont commented on GitHub (Nov 15, 2023):
see this link.
work for me
@github-actions[bot] commented on GitHub (May 19, 2024):
Issue is now considered stale. If you want to keep it open, please comment 👍
@Brendon-Mendicino commented on GitHub (Jun 16, 2024):
would it be possible to include the the
log_format proxyfrom a different file in order to override it using some mounted file? This allows for an easier way of overriding the default format for each service.writing our own custom
log_formatand then specifying it for each service is quite tedious.@ThatCoffeeGuy commented on GitHub (Aug 2, 2024):
This could integrate so well with GoAccess on default, but this questionable design choice makes it a headache to set it up. Please reconsider changing it back to the default logging format.