Skip to content

Commit

Permalink
Update nginx basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
ledongthuc committed Apr 4, 2021
1 parent 44c4613 commit 64f0e80
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nginx/authbasic/.htpasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user1:$apr1$NxhIYend$y81CRlV0MdpcwK1L/BasF.
user2:$apr1$w2KnEjmu$lrIJjCeGwtyo4.O2AyfNR.
26 changes: 26 additions & 0 deletions nginx/authbasic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
1. Generate auth file

```
htpasswd -c .htpasswd user1
htpasswd .htpasswd user2
```

2. Verify auth file

```
cat .htpasswd
```

3. Start app service and nginx

```
docker-compose up
```

4. Access URL

```
http://localhost:8080/
```

Enter username/password
14 changes: 14 additions & 0 deletions nginx/authbasic/custom.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
upstream appservice {
server appservice:30301;
}

server {
listen 8080;

auth_basic "Basic auth";
auth_basic_user_file /etc/apache2/.htpasswd;

location / {
proxy_pass http://appservice;
}
}
16 changes: 16 additions & 0 deletions nginx/authbasic/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"

services:
appservice:
image: ledongthuc/awssecretsmanagerui:latest
proxy:
container_name: reverse
hostname: reverse
image: nginx
ports:
- 8080:8080
volumes:
- ./custom.conf:/etc/nginx/conf.d/default.conf
- ./.htpasswd:/etc/apache2/.htpasswd
depends_on:
- appservice

0 comments on commit 64f0e80

Please sign in to comment.