Skip to content

antlafarge/http-share

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HTTP-SHARE

Share a directory through HTTP (protected by htaccess password).

Docker

# Create the login/password to access the http share.
echo "<LOGIN>:$(perl -le 'print crypt("<PASSWORD>", "1xzcq")')" > ~/http-share.htpasswd

docker run -d \
        --name <CONTAINER-NAME> \
        --restart <RESTART> \
    -v <PATH>:/usr/share/nginx/html/<SHARE-NAME>:ro \
    -v ~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro \
        -p <PORT>:80 \
    antlafarge/http-share:latest

Parameters indented twice are optional.

  • Replace <LOGIN> and <PASSWORD> by the login and password which will be required to access the http share.
  • Replace <CONTAINER-NAME> by the name you want for the container.
  • Replace <RESTART> by on-failure, unless-stopped or always.
  • Replace <PORT> by the http port you will open in your router NAT.
  • Replace <PATH> by the absolute path to the directory you want to share and <SHARE-NAME> by the name you want for the shared directory. The share-name is optional if you need to share only 1 directory. You can add many volumes if you want to share multiple directories (see examples).

Note : Do not delete the file http-share.htpasswd on your host machine, it will be used by the container.

Example

# Create the login/password to access the http share.
echo "admin:$(perl -le 'print crypt("MyGreatPassword", "1xzcq")')" > ~/http-share.htpasswd

docker run -d \
        --name http-share \
        --restart on-failure:2 \
    -v "/mnt/hdd/public:/usr/share/nginx/html/Public:ro" \
    -v "/mnt/hdd/shared:/usr/share/nginx/html/Shared:ro" \
    -v "~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro" \
        -p 8080:80 \
    antlafarge/http-share:latest

Parameters indented twice are optional.

Docker compose

echo "<LOGIN>:$(perl -le 'print crypt("<PASSWORD>", "1xzcq")')" > ~/http-share.htpasswd
services:
    http-share:
        image: antlafarge/http-share:latest
        container_name: <CONTAINER-NAME> # optional
        restart: <RESTART> # optional
        volumes:
            - "<PATH>:/usr/share/nginx/html/<SHARE-NAME>:ro"
            - "~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro"
        ports:
            - "<PORT>:80" # optional

Example

echo "admin:$(perl -le 'print crypt("MyGreatPassword", "1xzcq")')" > ~/http-share.htpasswd
services:
    http-share:
        image: antlafarge/http-share:latest
        container_name: http-share # optional
        restart: on-failure:2 # optional
        volumes:
            - "/mnt/hdd/public:/usr/share/nginx/html/Public:ro"
            - "/mnt/hdd/shared:/usr/share/nginx/html/Shared:ro"
            - "~/http-share.htpasswd:/etc/nginx/conf.d/.htpasswd:ro"
        ports:
            - "8080:80" # optional

Docker commands reminder

Container stop

docker stop http-share

Container restart

docker restart http-share

Container logs

docker logs --follow --tail 100 http-share

Container delete

docker rm -f http-share

Image delete

docker rmi antlafarge/http-share:latest

Compose start

cd /path/to/docker-compose.yml/directory/
docker-compose up -d

Compose stop

cd /path/to/docker-compose.yml/directory/
docker-compose down