Skip to content

Commit 82cd91c

Browse files
authored
Updated README.md
* Adding a TOC * Adding a basic authentication example
1 parent ee0a285 commit 82cd91c

File tree

1 file changed

+72
-5
lines changed

1 file changed

+72
-5
lines changed

README.md

+72-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
# nginx ui
1+
# nginx ui
22

3-
![Docker Image CI](https://github.com/schenkd/nginx-ui/workflows/Docker%20Image%20CI/badge.svg)
3+
![Docker Image CI](https://github.com/schenkd/nginx-ui/workflows/Docker%20Image%20CI/badge.svg)
44

55
![Image of Nginx UI](https://i.ibb.co/XXcfsDp/Bildschirmfoto-2020-06-20-um-18-40-27.png)
66

7-
![Image of Nginx UI](https://i.ibb.co/XXcfsDp/Bildschirmfoto-2020-06-20-um-18-40-27.png)
7+
Table of Contents
8+
9+
- [nginx ui](#nginx-ui)
10+
- [Introduction](#introduction)
11+
- [Setup](#setup)
12+
- [Example](#example)
13+
- [Docker](#docker)
14+
- [UI](#ui)
15+
- [Authentication](#authentication)
16+
- [Configure the auth file](#configure-the-auth-file)
17+
- [Configure nginx](#configure-nginx)
18+
19+
## Introduction
820

921
We use nginx in our company lab environment. It often happens that my
1022
colleagues have developed an application that is now deployed in our Stage
@@ -15,16 +27,31 @@ doing this for everyone anymore I thought a UI could help us all. If you
1527
feel the same way I wish you a lot of fun with the application and I am
1628
looking forward to your feedback, change requests or even a star.
1729

18-
## setup
30+
## Setup
1931

2032
Containerization is now state of the art and therefore the application is
2133
delivered in a container.
2234

23-
### docker
35+
### Example
36+
37+
- `-d` run as deamon in background
38+
- `--restart=always` restart on crash or server reboot
39+
- `--name nginxui` give the container a name
40+
- `-v /etc/nginx:/etc/nginx` map the hosts nginx directory into the container
41+
- `-p 8080:8080` map host port 8080 to docker container port 8080
42+
43+
```bash
44+
docker run -d --restart=always --name nginxui -v /etc/nginx:/etc/nginx -p 8080:8080 schenkd/nginx-ui:latest
45+
```
46+
47+
### Docker
2448

2549
Repository @ [DockerHub](https://hub.docker.com/r/schenkd/nginx-ui)
2650

51+
Docker Compose excerpt
52+
2753
```yaml
54+
# Docker Compose excerpt
2855
services:
2956
nginx-ui:
3057
image: schenkd/nginx-ui:latest
@@ -47,3 +74,43 @@ into the Nginx UI Main Config menu item.
4774
4875
Adding a domain opens an exclusive editing window for the configuration
4976
file. This can be applied, deleted and enabled/disabled.
77+
78+
## Authentication
79+
80+
[BasicAuth with nginx](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/)
81+
82+
In general, this app does not come with authentication. However, it is easy to setup basic auth to restrict unwanted access.
83+
Here is how this can be done when using nginx.
84+
85+
### Configure the auth file
86+
87+
1. Verify that `apache2-utils` (Debian, Ubuntu) or `httpd-tools` (RHEL/CentOS/Oracle Linux) is installed
88+
2. Run the htpasswd utility to create a new user and set a passwort.
89+
- Make sure, that the directory exists
90+
- Remove the `-c` flag, if you have created a user before, since it creates the inital user/passwort file
91+
- `sudo htpasswd -c /etc/apache2/.htpasswd user1`
92+
93+
### Configure nginx
94+
95+
The following example adds basic auth to our nginxui app running in a docker container with a mapped port 8080.
96+
In this case, it will be accessible via nginx.mydomain.com
97+
98+
```none
99+
server {
100+
server_name nginx.mydomain.com;
101+
102+
location / {
103+
proxy_pass http://127.0.0.1:8080/;
104+
}
105+
106+
auth_basic "nginxui secured";
107+
auth_basic_user_file /etc/apache2/.htpasswd;
108+
109+
# [...] ommited ssl configuration
110+
}
111+
```
112+
113+
1. Add above nginx conf to your `/etc/nginx/my.conf` file
114+
2. Run `nginx -t` to make sure, that your config is valid
115+
3. Run `systemctl restart nginx` (or equivalent) to restart your nginx and apply the new settings
116+
4. Your nginx ui is now accessible at nginx.mydomain.com and will correctly prompt for basic auth

0 commit comments

Comments
 (0)