Which fields can the access log record, and how to write the content received from the client in a secure way?

📅 October 9, 2026 👁️ 13

Which fields can the server's access log record depends on how the format instruction is拼,not a fixed table structure. nginx's log module useslog_formatDefine naming format, useaccess_logQuotation format, fields are composed of variables. To judge security, first divide the fields into two categories according to「Who provides this value」The source address, request line, status code, and processing time are generated by the server side, and the source path and client identifier are completely controlled by the requesting party.The latter can contain any characters or be entirely forged.

The log format is拼凑出来的指令,not fixed.

log_formatThe value is a template with variables, named after it can be referenced by multipleaccess_logreferences. The same log can be distinguished by format for different purposes: a set for troubleshooting performance, a set for counting sources, a set for auditing, and fields do not have to overlap.

There are two details that will affect the subsequent parsing. First, when a variable cannot be retrieved, it is recorded as a hyphen, so the parsing rules must accept the empty value form; second, the escaping method,log_formatThe escape parameter can be default, , or none, the default is default-default will escape double quotes, backslashes, and characters with values less than 32 or greater than 126 will escape according to the rules of JSON strings, none will close the escape

Which fields come from the request itself and which come from the server

field Source Client可控 Suggestion
Source address Connection layer No (can be rewritten by proxy) Reserved, as the minimum available set
Request line and method a request Is 保留,用于定位异常路径
Status code Server Response No retains
Processing Time Server No Reserved for performance troubleshooting
Source and client identifier Request Headers Is Reserved but depends on escaping
Complete request header a request Is Caution, large volume and may contain identity credentials

The source address, request, status code, source, and client identifier are the minimum set of data used for troubleshooting. Whether to write the entire request header into the log should be judged separately: it may contain identity information. Once this value is in the log, the file itself becomes sensitive data.

Why escape the client可控 field

The route and client identifier are emitted by the visitor's own program, and the content is not constrained. Inserting newline characters, quotes, or control characters can cause two types of consequences: field misalignment during parsing, a single request being split into multiple records, or vice versa; or forging a line that appears normal, making it impossible to tell who wrote it after the fact.

The deeper risk is at the log consumption end. When logs are read by the background interface, search panel, or report, unescaped content may be executed on the display side, which is a common entry point for stored cross-site scripting. AnQi CMS has protected against XSS and SQL injection within the site, but logs from writing to analysis often cross multiple tools, and the other end still depends on escaping and format constraints, and cannot assume that the downstream will handle it.

Escape as default when writing, and use escaping when connecting to a JSON analysis pipeline; none is only suitable for completely trusted scenarios that will not be parsed again.

Log is configured for the entire site or by path

access_logIt can appear at different levels of server configuration, covering the three levels of entire site, site, and path; where a request is eventually logged at a certain level depends on the context at the end of processing ——Requests that have undergone internal redirection may have different recording locations from the originally matched path.

When running multiple sites on a single host, this directly affects whether fault troubleshooting can clarify responsibility: specifying log files separately by site is easier to locate than using a single large file for the entire site. For those deployed with Docker images, pay attention to whether the logs are output to a volume outside the container; otherwise, they will be lost after a restart; for those deployed with Baota panel or aaPanel, the log path and splitting strategy are usually in two places, the panel and server configuration, and it is necessary to confirm which one is actually effective after modification.

The fields to keep and the handling to block

In addition to retaining the minimum available set, there are two things to be implemented. First is archiving and retention: logs should be cut according to the cycle and included in the backup range, only keeping the daily files will cause a gap in post-event traceability; whether the log file of the next day is included in the backup record should be written. Second is desensitization on the collection side: excluding headers with credentials from the format is much more reliable than post-cleaning.

Common questions

Question: Should the size of the response body be recorded in the log?Answer: Yes. It is a commonly used basis for judging whether compression and caching are effective, and does not involve client controllable content.

Question: Isn't it safer to turn on JSON escaping?Answer: Escaping solves field misalignment and control characters, changing the format to JSON does not change the fact that 'Content is provided by the requestor', still need to limit which request headers to record.

Question: If multiple websites share one host, should the logs be separated into different files?Answer: It is recommended to separate by site. When sharing files, troubleshooting should first be done by domain name, which is costly and easy to miss.

Related articles

After changing the domain name, should the verification file submitted to the search engine be placed again?

To be placed again. The purpose of the key and the verification file is to prove the ownership of the current domain and host, which is bound to the 'current site', not the machine that was uploaded initially. After changing the domain name, it should be placed again in the root directory of the new domain name or in a publicly accessible folder on the same host and re-verified. At the same time, the 301 jump, sitemap, and in-site link push queue from the old domain name to the new domain name should be rearranged separately - the jump relationship and the communication channel are two different things.

2026-10-09

Is the multilingual site translated as a whole page or filled in field by field, how much is the maintenance difference

Full-page translation generates a complete page at one time, saving labor on the initial generation, but the cost is in the subsequent changes to the source page; manual entry of each field is more controllable, with labor spent on each change. The basis for judgment is not which is more advanced, but the frequency of revision and the number of sites: columns with frequent changes in source content are suitable for field-by-field, long-tail articles and brand site expansion are suitable for full-page generation followed by proofreading, and when multiple sites share a backend, it is necessary to clarify the maintenance boundaries first.

2026-10-09

How should the strength and error lock of the password recovery verification code be configured?

The verification codes for password recovery, login verification, and form anti-robot verification are not the same thing: recovery type requires random source sufficient, short validity period, error count lock binding to the same entry; form type requires blocking batch submission, which can be handed over to interactive verification such as reCAPTCHA. The same CMS has also strengthened in the recent version updates in this direction, changing the verification code to 6-digit secure random generation and adding expiration time and error count lock.

2026-10-09

Who should write the title, keywords, and description, and how should handwritten and automatic generation be coordinated

The automation risks for the title, keywords, and description are different: the title is recommended to be finalized manually, with candidates provided by the system; keywords are suitable for semi-automatic reclassification to the keyword library; the description can be generated automatically first and then reviewed by humans to ensure consistency, as it will be independently displayed by search engines. The common division of labor is for the system to produce the initial draft, humans to manage facts and tone, and the automatically generated results to be advanced to draft or pending publication status, and then released after acceptance.

2026-10-09

Can anonymous visitors read the comments under the unposted articles?

Can anonymous read the comments under the unissued article, it depends on which layer the visibility is determined. The text and the comments under it are two layers of visibility: the list interface filters by status, which does not mean the detail interface also filters. A mainstream program in the security version of October 2026 has fixed 'private and unissued article comments can be read without authorization', indicating that vulnerabilities often occur in child objects rather than parent objects.

2026-10-09

What should be written after each link in the documentation file for the large model site?

In the site description document for large models, only the project name is required, and the rest of the paragraphs are organized as agreed. Each link entry is written as a bracket name followed by a parenthesis address, which may optionally be followed by a colon and a sentence of explanation. This explanation should not repeat the title but should state what the page answers, who it is for, and the date it was last updated; the sitemap and keyword library are responsible for the other half of the clues.

2026-10-09

What should the AI engine provide when it needs the whole site content list, the site map and the model description file respectively?

The site map and the description file for large models do not answer the same question. The site map is an address list, providing URL, last modified time, and priority, aimed at general web crawlers; the model description file is a semantic list, using grouping and each summary to describe what this page is about and who it is for, aimed at language models. Both are automatically generated by the system, and the entry and summary are manually maintained.

2026-10-09

Can an editor account change the homepage display position, and how should role permissions be restricted?

Can authors or editors change the homepage display position, restricted by 'ability impact range' instead of headcount? Actions affecting the entire site's display should not be given to submission roles. A mainstream program in the security version of October 2026 listed 'author role can execute pinned articles' as a vulnerability fix. The site sets the accessible range according to user groups and group permissions, and high-risk site-level interfaces are not open by default.

2026-10-09