Merge 904d8e9537
into 42c8b0c4c9
This commit is contained in:
commit
cb2d2e41e9
2 changed files with 9 additions and 0 deletions
|
@ -315,6 +315,8 @@ docker run -d -p 80:80 -p 443:443 \
|
|||
nginxproxy/nginx-proxy
|
||||
```
|
||||
|
||||
It is also possible to create the default htpasswd file /etc/nginx/htpasswd/default that is used when no file named after $VIRTUAL_HOST is present. This can be used when all virtual host should have the same Basic Authentication anyway or as an extra security measure to make sure that no service is exposed to the wild internet without authentication even if there is a error in the configuration and/or file naming.
|
||||
|
||||
You'll need apache2-utils on the machine where you plan to create the htpasswd file. Follow these [instructions](http://httpd.apache.org/docs/2.2/programs/htpasswd.html)
|
||||
|
||||
### Custom Nginx Configuration
|
||||
|
|
|
@ -354,6 +354,9 @@ server {
|
|||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||
{{ else if (exists "/etc/nginx/htpasswd/default") }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file /etc/nginx/htpasswd/default;
|
||||
{{ end }}
|
||||
{{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
|
||||
|
@ -402,9 +405,13 @@ server {
|
|||
{{ else }}
|
||||
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||
{{ end }}
|
||||
|
||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||
{{ else if (exists "/etc/nginx/htpasswd/default") }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file /etc/nginx/htpasswd/default;
|
||||
{{ end }}
|
||||
{{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
|
||||
include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
|
||||
|
|
Loading…
Reference in a new issue