diff --git a/Dockerfile b/Dockerfile index 891a7e4..778ba33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM nginx:alpine -MAINTAINER Mohammad Naghavi +LABEL author="Mohammad Naghavi " ADD default.conf /etc/nginx/conf.d/default.conf ADD css/ /opt/www/file-browser/css/ diff --git a/Dockerfile-rootless b/Dockerfile-rootless new file mode 100644 index 0000000..7125a50 --- /dev/null +++ b/Dockerfile-rootless @@ -0,0 +1,12 @@ +FROM nginxinc/nginx-unprivileged:stable-alpine + +LABEL author="Mohammad Naghavi " + +ADD default-rootless.conf /etc/nginx/conf.d/default.conf +ADD css/ /opt/www/file-browser/css/ +ADD image/ /opt/www/file-browser/image/ +ADD js/ /opt/www/file-browser/js/ +ADD index.html /opt/www/file-browser/ + +VOLUME /opt/www/files/ +EXPOSE 8080 \ No newline at end of file diff --git a/README.md b/README.md index 9d9bb68..e72a4f7 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,17 @@ A sample nginx configuration is also included which mounts **file browser** unde Mainly for demonstration purposes a docker image is also available [here](https://hub.docker.com/r/mohamnag/nginx-file-browser/). In order to use this docker image, the volume which has to be served should -be mounted under `/opt/www/files/` and port `80` of container shall be mapped +be mounted under `/opt/www/files/` and port `80` (root) or `8080` (rootless)) of container shall be mapped to a proper port on host. A proper run would look like: +root ``` $ docker run -p 8080:80 -v /path/to/my/files/:/opt/www/files/ mohamnag/nginx-file-browser ``` +rootless: +``` +$ docker run -p 8080:8080 -v /path/to/my/files/:/opt/www/files/ mohamnag/nginx-file-browser +``` With container up and running you can point your browser to IP of docker host with given port to view the files. For example with above run command assuming docker host having IP with `192.168.0.200` we have to navigate to this URL: diff --git a/default-rootless.conf b/default-rootless.conf new file mode 100644 index 0000000..6600917 --- /dev/null +++ b/default-rootless.conf @@ -0,0 +1,26 @@ +server { + listen 8080; + server_name localhost; + + root /opt/www/; + index index.html index.htm; + + location /files/ { + alias /opt/www/files/; + index ___i; # we really need no index here, just listing files + + autoindex on; + autoindex_format json; + disable_symlinks off; + } + + location / { + root /opt/www/file-browser/; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + +} \ No newline at end of file