Initial commit.
This commit is contained in:
24
README.md
Normal file
24
README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Generate user-password tuple
|
||||
Install utility tool:
|
||||
```bash
|
||||
sudo apt install apache2-utils
|
||||
```
|
||||
|
||||
Generate tuple when file `.htpasswd` does not exist yet:
|
||||
```bash
|
||||
htpasswd -c ./.htpasswd myuser
|
||||
# Then type password twice
|
||||
```
|
||||
|
||||
Generate tuple when file `.htpasswd` already exists:
|
||||
```bash
|
||||
htpasswd ./.htpasswd myuser
|
||||
# Then type password twice
|
||||
```
|
||||
# Launch server
|
||||
```bash
|
||||
docker compose up
|
||||
```
|
||||
|
||||
## Access to secret file
|
||||
[http://localhost:50080/secret-file.txt](http://localhost:50080/secret-file.txt)
|
||||
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
container_name: nginx_with_auth
|
||||
ports:
|
||||
- "50080:80"
|
||||
volumes:
|
||||
- ./secret-file.txt:/app/secret-file.txt:ro
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./.htpasswd:/etc/nginx/.htpasswd:ro
|
||||
19
nginx.conf
Normal file
19
nginx.conf
Normal file
@@ -0,0 +1,19 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 80;
|
||||
server_name votre_domaine.com;
|
||||
|
||||
location /secret-file.txt {
|
||||
auth_basic "Accès restreint";
|
||||
auth_basic_user_file /etc/nginx/.htpasswd;
|
||||
|
||||
# Autres directives pour servir votre fichier
|
||||
# Par exemple :
|
||||
alias /app/secret-file.txt;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
secret-file.txt
Normal file
1
secret-file.txt
Normal file
@@ -0,0 +1 @@
|
||||
Hello world!
|
||||
Reference in New Issue
Block a user