Skip to content

Commit 927fa5b

Browse files
committed
Update nginx authentication config
1 parent d7d3c36 commit 927fa5b

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

README.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ for all `POST`/`PUT` and `DELETE` http calls.
7878
This example shows how to configure the NGINX inside the docker image
7979
to be password protected using http basic auth.
8080

81-
1) Create your `htpasswd` file.
82-
2) And a custom `default.conf` NGINX config:
81+
1) Create your [`.htpasswd` file](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/#creating-a-password-file).
82+
2) And a custom `default` NGINX config:
8383

8484
```
8585
upstream python_backend {
@@ -90,40 +90,41 @@ to be password protected using http basic auth.
9090
listen 80 default_server;
9191
listen [::]:80 default_server;
9292
93-
auth_basic "Administrator’s Area";
94-
auth_basic_user_file htpasswd;
95-
9693
root /var/www/html;
9794
98-
# Add index.php to the list if you are using PHP
99-
index index.html index.htm index.nginx-debian.html;
95+
add_header Content-Security-Policy "frame-ancestors 'self';";
96+
index index.html index.htm index.pdf /index.html;
10097
10198
server_name _;
10299
103100
location /doc {
104101
root /var/docat;
105-
autoindex on;
106-
autoindex_format json;
107102
}
108103
109104
location /api {
105+
limit_except GET HEAD {
106+
auth_basic 'Restricted';
107+
auth_basic_user_file /etc/nginx/.htpasswd;
108+
}
109+
110110
client_max_body_size 100M;
111111
proxy_pass http://python_backend;
112112
}
113113
114114
location / {
115+
try_files $uri $uri/ =404;
115116
}
116117
}
117118
```
118119

119-
3) Mounted to the correct location inside the container:
120+
1) Mounted to the correct location inside the container:
120121

121122
```
122123
docker run \
123124
--detach \
124125
--volume $PWD/docat-run:/var/docat/ \
125-
--volume $PWD/nginx/default.conf:/etc/nginx/http.d/default.conf \
126-
--volume $PWD/nginx/htpasswd:/etc/nginx/htpasswd \
126+
--volume $PWD/nginx/default:/app/docat/docat/nginx/default \
127+
--volume $PWD/nginx/.htpasswd:/etc/nginx/.htpasswd \
127128
--publish 8000:80 \
128129
ghcr.io/docat-org/docat
129130
```
@@ -136,7 +137,7 @@ to be password protected using http basic auth.
136137
It is possible to configure some things after the fact.
137138

138139
1. Create a `config.json` file
139-
2. Mount it inside your docker container `--volume /path/to/config.json:/var/docat/doc/config.json`
140+
2. Mount it inside your docker container `--volume $PWD/config.json:/var/docat/doc/config.json`
140141

141142
Supported config options:
142143

0 commit comments

Comments
 (0)