Opened 6 years ago

Closed 6 years ago

#1592 closed defect (duplicate)

"nginx -s" doesn't read error_log configuration

Reported by: https://stackoverflow.com/users/4861570/stefan Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.15.x
Keywords: readonly logging Cc:
uname -a: 'uname' is not recognized as an internal or external command,
operable program or batch file.
nginx -V: nginx version: nginx/1.15.1
built by cl 16.00.40219.01 for 80x86
built with OpenSSL 1.0.2o 27 Mar 2018
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-8.42 --with-zlib=objs.msvc8/lib/zlib-1.2.11 --with-select_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-openssl=objs.msvc8/lib/openssl-1.0.2o --with-openssl-opt=no-asm --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module

Description

I'm using recent nginx 1.15.1 on Microsoft Windows 7 (6.1.7601 SP1) and trying to set it up as a small webserver on a readonly (network-)drive. (I previously used miniweb from stanleyhuang before, but that isn't maintained anymore and has severe security flaws.)

It was a small challenge to work around of many write operations of nginx, but I finally got it running - with one small exception: If I want to shut down nginx with "nginx.exe -s quit" this exe *always* wants to write something like "2018/07/06 09:51:42 [notice] 558324#550736: signal process started" to logs/error.log, despite in config I clearly wrote "error_log nul emerg;" so:

  • write error log to nul (windows equivalent to /dev/null")
  • only write logs with emergency level (written log has notice level)

This write action pops up an error message like https://i.stack.imgur.com/68lFU.png which would confuse the user.
So my best guess is that the call doesn't read in / consider my configuration, which I would call a bug.

Steps to reproduce:

  • Download nginx 1.15.1 for Windows on a Windows (7) machine
  • Extract and copy files to a write-protected network drive or use e.g. VeraCrypt that can mount a container readonly
  • use attached config to configure nginx
  • start nginx - should work like a charm
  • shutdown nginx with "nginx.exe -s quit"

Expected behavior:

  • nginx shuts down gracefully

Currently buggy behavior:

  • Windows popup of Write Protect Error pops up because ngnix wants to write a notice to logs/error.log (which isn't configured as error log file)

Attachments (1)

nginx.conf (1.1 KB ) - added by https://stackoverflow.com/users/4861570/stefan 6 years ago.
example configuration with all write operations (except pid) turned off

Download all attachments as: .zip

Change History (3)

by https://stackoverflow.com/users/4861570/stefan, 6 years ago

Attachment: nginx.conf added

example configuration with all write operations (except pid) turned off

comment:1 by Maxim Dounin, 6 years ago

The problem is as follows:

  • Signal process, while it parses the configuration, never fully applies it. In particular, it doesn't tries to switch to error logs configured, since it remains interactive and needs to be able to output errors, if any, to stderr. That is, it preserves the same logs as used during initial startup process.
  • Initial startup process logs to stderr and to the complied-in error log (see ticket #147).

Without nginx being able to open compiled-in error log for writing, you'll see something like:

nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (19: The media is write protected)

on the console. This won't prevent nginx from working though. Also, no popups are expected - and this is not something I get while testing on Windows 10 with a read-only network drive.

Could you please confirm that the dialog is something you get from Windows when using a read-only network drive?

comment:2 by Maxim Dounin, 6 years ago

Resolution: duplicate
Status: newclosed

Feedback timeout. Closing this as a duplicate of #147.

Note: See TracTickets for help on using tickets.