Opened 8 years ago

Closed 8 years ago

#254 closed defect (worksforme)

include directive fails when included file does not contain a new line

Reported by: Roberto Hidalgo Owned by: Maxim Dounin
Priority: minor Milestone:
Component: nginx-core Version: 1.2.x
Keywords: include Cc:
uname -a: Darwin mariaLuisa.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
nginx -V: nginx: nginx version: nginx/1.0.25
nginx: built by gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
nginx: TLS SNI support enabled
nginx: configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-ipv6 --add-module=../masterzen-nginx-upload-progress-module-436ec80/ --add-module=../nginx_upload_module-2.2.0/ --add-module=../nginx_http_push_module-0.69/ --add-module=/usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/passenger-3.0.8/ext/nginx --add-module=../simpl-ngx_devel_kit-bc97eea/ --add-module=../agentzh-set-misc-nginx-module-7adef5a/ --with-cc-opt=-Wno-deprecated-declarations

Description

The include directive fails to work when loading mime.types if this file does not contain a new line before declaring types {

# Example nginx.conf

http {
    include mime.types;
}

# Example mime.types that works


types {
     text/html                             html htm shtml;
}

# Example mime.types that DOES NOT work

types {
     text/html                             html htm shtml;
}

Attachments (3)

workining.mime.types (13.4 KB ) - added by Roberto Hidalgo 8 years ago.
Working mime.types
problematic.mime.types (13.4 KB ) - added by Roberto Hidalgo 8 years ago.
Problematic mime.types
nginx configuration (3.6 KB ) - added by Roberto Hidalgo 8 years ago.
working nginx configuration

Download all attachments as: .zip

Change History (10)

comment:1 by Maxim Dounin, 8 years ago

I don't see any problems with this, you may want to be a bit more specific. In particular, you may want to provide hexdump of files you test (using hd or xxd).

I suppose you have no newline at end of the file which doesn't work - which essentially makes it non-text (and one can't expect it will work as a configuration file).

by Roberto Hidalgo, 8 years ago

Attachment: workining.mime.types added

Working mime.types

by Roberto Hidalgo, 8 years ago

Attachment: problematic.mime.types added

Problematic mime.types

by Roberto Hidalgo, 8 years ago

Attachment: nginx configuration added

working nginx configuration

comment:2 by Roberto Hidalgo, 8 years ago

Thanks for your reply Maxim, hope you find the attached hexdumps useful.

I did not know that not having a new line at the end of the file made it essentially non-text, however, I am talking about not having a new line at the beginning that makes nginx ignore this file. I have no problems loading any other file, such as the ones for each virtual host or fastgci params even if they have no new lines both at the beginning or the end of the file.

comment:3 by Maxim Dounin, 8 years ago

Dumps you provided are fine, and I don't see any problems with them (to make sure just tested with nginx 1.2.5 on mac os x), except that nginx.conf is incomplete due to include /etc/nginx/sites-enabled/* used.

Please define "does not work" (that is - exact steps to reproduce the problem, result you see, result you expect to see) and please make sure you are able to reproduce the problem without 3rd party modules/patches.

comment:4 by Roberto Hidalgo, 8 years ago

By "does not work" I mean, the static files served are not served with the correct Content-type, but rather the MIME type specified in default_type. As if, (as I stated previously) nginx ignores [the mime.types] file.

The include just loads a simple

server {
	listen 80;
	server_name test.dev;
	root /testing;
	index index.html;
}

The contents of the testing dir are just empty index.html and test.css files.

To reproduce the problem I am reporting, try removing any new lines at the beginning of the mime.types file file, start NGINX, and inspect the HTTP headers sent by NGINX of a static .css file. The expected result would be having a header like Content-type: text/css; the resulting headers include, on the other hand, Content-type: application/octet-stream.

I tested in that way with a clean 1.2.5 nginx installation on Mac OS X, with no 3rd party modules or patches at all.

Last edited 8 years ago by Roberto Hidalgo (previous) (diff)

comment:5 by Maxim Dounin, 8 years ago

Unfortunately I'm still not able to reproduce the problem you are talking about, neither I see problems in the code.

Please provide exact steps to reproduce the problem, including commands you've used to build nginx (ideally - shell script which builds nginx and tests for the problem). Please also provide nginx -V output of nginx wihout 3rd party modules you've used for tests, test output (e.g. curl -svo /dev/null http://127.0.0.1/index.html output) and debug log of both working and non-working cases, as well as self-consistent snapshots of configurations.

Please also try to reproduce the problem on various other hosts yourself. The issue might be specific to your exact system for some reason, and it would be good to make sure steps to reproduce you'll provide do actually work on other hosts.

comment:6 by maxim, 8 years ago

Owner: changed from somebody to Maxim Dounin
Status: newassigned

comment:7 by Maxim Dounin, 8 years ago

Resolution: worksforme
Status: assignedclosed

Feedback timeout. We aren't able to reproduce the problem reported, and there is no confirmation the problem is reproducible on systems other than original reporter's one.

Note: See TracTickets for help on using tickets.