Opened 8 years ago

Closed 8 years ago

#863 closed enhancement (worksforme)

Support for serving any directory as a low priviliged user

Reported by: stackoverflow.com/users/870207/teknopaul Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.9.x
Keywords: run as low priviliged user serving arbitrary directory Cc:
uname -a: Linux [redacted] 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.9.3 (Ubuntu)
built with OpenSSL 1.0.2d 9 Jul 2015
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_secure_link_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-threads --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/headers-more-nginx-module --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-auth-pam --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-cache-purge --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-dav-ext-module --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-development-kit --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-echo --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/ngx-fancyindex --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-http-push --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-lua --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-upload-progress --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/nginx-upstream-fair --add-module=/build/nginx-1NwJqb/nginx-1.9.3/debian/modules/ngx_http_substitutions_filter_module

Description

python and other HTTP servers support instantly serving the current directory ans the current user.

e.g. python SimpltHttpServer .

nginx does not support this due to touching files that require root access no matter what the configuration, this depends on compile time options. If an option were provided then simply

nginx . (-whatever or -c ./nginx.conf) could be added to development and test workflows, e.g. put in a Makefile.

Without this, we have to avoid using advanced features of nginx in dev workflows and stick to lowest common denominator for any HTTP server.

I'll make this priority minor but when nginx 2.0 supports really cool JavaScript config this is going to be higher priority because lack of this feature will mean any bug related to these new nginx specific features will get left to QA and integration deployments rather than being resolved part of development processes.

Change History (1)

comment:1 by Maxim Dounin, 8 years ago

Resolution: worksforme
Status: newclosed
Type: defectenhancement

All files nginx tries to use can be overridden using configuration directives. And you can set prefix path using the -p switch, so to start serving files in current directory you can do something like this:

$ nginx -p . -c /path/to/nginx.conf

Using an nginx.conf like this one:

daemon off;

error_log /dev/stderr;
pid /tmp/nginx.pid;

events {
}

http {
    root .;
    access_log /dev/stderr;

    server {
        listen 8080;
    }
}
Note: See TracTickets for help on using tickets.