I'd like to list a directory on my server by using my web browser. The directory is /srv/downloads/
I installed nginx server to do that. Here is the configuration files:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
and the .conf file inside the conf.d directory is:
server {
listen 80 default_server;
server_name example.org;
root /srv;
client_max_body_size 64M;
location /downloads/ {
autoindex on;
alias /srv/downloads/;
allow 192.168.0.0/24;
allow 10.212.116.0/23;
deny all;
}
}
But when I try to access http://192.168.0.2/downloads/
, I am able to list directories but not everything. Below is what happens :
2015/04/21 17:08:54 [crit] 12839#0: *1 stat() "/srv/downloads/fix_kernel_doc.patch.done" failed (13: Permission denied), client: 192.168.0.26, server: example.org, request: "GET /downloads/ HTTP/1.1", host: "192.168.0.2"
As shown in the nginx.conf, nginx server is ran by the user "nginx". So I did the following:
[root@srv]# su -l nginx -s /bin/stat /srv/downloads/fix_kernel_doc.patch.done
Last login: mar. avril 21 17:30:19 CEST 2015 on pts/0
File: '/srv/downloads/fix_kernel_doc.patch.done'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 85524762 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ is) Gid: ( 1000/ devs)
Context: system_u:object_r:var_t:s0
Access: 2015-04-21 17:22:48.393259661 +0200
Modify: 2015-04-21 17:22:48.393259661 +0200
Change: 2015-04-21 17:22:48.393259661 +0200
Birth: -
My user nginx is in the "devs" group. I also tried with the user www-data just to be sure but it's not working neither.
Any idea please ? Thanks