Nginx UI allows you to access and modify the nginx configurations files without cli.

Overview

nginx ui

Docker Image CI

Image of Nginx UI

Table of Contents

Introduction

We use nginx in our company lab environment. It often happens that my colleagues have developed an application that is now deployed in our Stage or Prod environment. To make this application accessible nginx has to be adapted. Most of the time my colleagues don't have the permission to access the server and change the configuration files and since I don't feel like doing this for everyone anymore I thought a UI could help us all. If you feel the same way I wish you a lot of fun with the application and I am looking forward to your feedback, change requests or even a star.

Setup

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

Example

  • -d run as deamon in background
  • --restart=always restart on crash or server reboot
  • --name nginxui give the container a name
  • -v /etc/nginx:/etc/nginx map the hosts nginx directory into the container
  • -p 8080:8080 map host port 8080 to docker container port 8080
docker run -d --restart=always --name nginxui -v /etc/nginx:/etc/nginx -p 8080:8080 schenkd/nginx-ui:latest

Docker

Repository @ DockerHub

Docker Compose excerpt

# Docker Compose excerpt
services:
  nginx-ui:
    image: schenkd/nginx-ui:latest
    ports:
      - 8080:8080
    volumes:
      - nginx:/etc/nginx

UI

Image of Nginx UI

With the menu item Main Config the Nginx specific configuration files can be extracted and updated. These are dynamically read from the Nginx directory. If a file has been added manually, it is immediately integrated into the Nginx UI Main Config menu item.

Image of Nginx UI

Adding a domain opens an exclusive editing window for the configuration file. This can be applied, deleted and enabled/disabled.

Authentication

BasicAuth with nginx

In general, this app does not come with authentication. However, it is easy to setup basic auth to restrict unwanted access. Here is how this can be done when using nginx.

Configure the auth file

  1. Verify that apache2-utils (Debian, Ubuntu) or httpd-tools (RHEL/CentOS/Oracle Linux) is installed
  2. Run the htpasswd utility to create a new user and set a passwort.
    • Make sure, that the directory exists
    • Remove the -c flag, if you have created a user before, since it creates the inital user/passwort file
    • sudo htpasswd -c /etc/apache2/.htpasswd user1

Configure nginx

The following example adds basic auth to our nginxui app running in a docker container with a mapped port 8080. In this case, it will be accessible via nginx.mydomain.com

server {
    server_name nginx.mydomain.com;

    location / {
        proxy_pass http://127.0.0.1:8080/;
    }

    auth_basic "nginxui secured";
    auth_basic_user_file /etc/apache2/.htpasswd;

    # [...] ommited ssl configuration
}
  1. Add above nginx conf to your /etc/nginx/my.conf file
  2. Run nginx -t to make sure, that your config is valid
  3. Run systemctl restart nginx (or equivalent) to restart your nginx and apply the new settings
  4. Your nginx ui is now accessible at nginx.mydomain.com and will correctly prompt for basic auth
Comments
  • Fixed app/templates/new_domain.j2

    Fixed app/templates/new_domain.j2

    Fix invalid Nginx config template and change access_log to /tmp/{{ name }}.access.log to avoid file permission.

    from

    {
        listen          80;
        server_name     {{ name }},
        access_log      logs/{{ name }}.access.log main;
    
        location / {
            proxy_pass      http://127.0.0.1:8080;
        }
    
    }
    

    to

    server {
        listen          80;
        server_name     {{ name }};
        access_log      /tmp/{{ name }}.access.log main;
    
        location / {
            proxy_pass  http://127.0.0.1:8080;
        }
    }
    
    
    opened by narate 4
  • Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

    Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

    ❯ docker run -d --restart=always --name nginxui -p 3333:8080 -v /etc/nginx:/nginx schenkd/nginx-ui:latest

    ❯ docker logs nginxui *** Starting uWSGI 2.0.18 (64bit) on [Tue Jun 23 01:55:51 2020] *** compiled with version: 9.3.0 on 21 June 2020 09:42:26 os: Linux-5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 nodename: f5f7495cb4e6 machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 8 current working directory: /webapp detected binary path: /usr/local/bin/uwsgi uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** *** WARNING: you are running uWSGI without its master process manager *** your memory page size is 4096 bytes detected max file descriptor number: 1048576 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uWSGI http bound on 0.0.0.0:8080 fd 4 spawned uWSGI http 1 (pid: 6) uwsgi socket 0 bound to TCP address 127.0.0.1:33773 (port auto-assigned) fd 3 uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** Python version: 3.7.7 (default, Jun 3 2020, 19:58:28) [GCC 9.3.0] Python main interpreter initialized at 0x55f7fbfe7ce0 uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 145984 bytes (142 KB) for 8 cores *** Operational MODE: threaded *** WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x55f7fbfe7ce0 pid: 1 (default app) uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** *** uWSGI is running in multiple interpreter mode *** spawned uWSGI worker 1 (and the only) (pid: 1, cores: 8) [2020-06-23 01:56:30,544] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "./app/ui/views.py", line 15, in index config = [f for f in os.listdir(nginx_path) if os.path.isfile(os.path.join(nginx_path, f))] FileNotFoundError: [Errno 2] No such file or directory: '/etc/nginx' [pid: 1|app: 0|req: 1/1] 172.17.0.1 () {48 vars in 914 bytes} [Tue Jun 23 01:56:30 2020] GET / => generated 290 bytes in 3 msecs (HTTP/1.1 500) 2 headers in 99 bytes (1 switches on core 1) [pid: 1|app: 0|req: 2/2] 172.17.0.1 () {46 vars in 832 bytes} [Tue Jun 23 01:56:30 2020] GET /favicon.ico => generated 232 bytes in 0 msecs (HTTP/1.1 404) 2 headers in 87 bytes (1 switches on core 1)

    ❯ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f5f7495cb4e6 schenkd/nginx-ui:latest "uwsgi --http 0.0.0.…" 32 seconds ago Up 30 seconds 0.0.0.0:3333->8080/tcp nginxui

    unable to run on http://localhost:3333/

    Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

    opened by Raju 4
  • /static/themes missing on manual build

    /static/themes missing on manual build

    I'm running on Aarch64 so had to build from source as you only seem to have Arm64 containers.

      nginxui:
        container_name: nginxui
        build: https://github.com/schenkd/nginx-ui.git
        volumes:
          - /opt/nginx:/etc/nginx
        restart: unless-stopped
        networks:
          - internal
    

    However there is no content in the /static/themes folder in the web app, these means the outline-icons aren't loaded.

    bug 
    opened by mattheys 4
  • Configuration if Nginx also running in container

    Configuration if Nginx also running in container

    Can you give an example of the docker startup command or the docker-compose.yml if the nginx instance also running in a docker container. How can we link both containers?

    question 
    opened by JoLander 3
  • No authentication mechanisms

    No authentication mechanisms

    Currently there is no way to secure the web interface. The nginx directory is directly mapped to the Docker container and any person on the same network can access the control panel.

    I suggest either implementing any authentication mechanism like username/password authentication backed up by a database or warning about this in README.md and suggesting to enable basic HTTP authentication at least.

    question 
    opened by maxkreja 3
  • :latest crashes during startup

    :latest crashes during startup

    Im trying to setup nginx-ui, but executing docker run -d --restart=always --name nginxui -p 7777:8080 schenkd/nginx-ui:latest -v /etc/nginx:/nginx results in the container not starting correctly and constantly crashing.

    docker logs nginxui results in the following message, without a real error info:

    *** Starting uWSGI 2.0.18 (64bit) on [Mon Jun 22 08:00:31 2020] *** compiled with version: 9.3.0 on 21 June 2020 09:42:26 os: Linux-5.4.0-33-generic #37-Ubuntu SMP Thu May 21 12:53:59 UTC 2020 nodename: eada146745a8 machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 1 current working directory: /webapp detected binary path: /usr/local/bin/uwsgi uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** *** WARNING: you are running uWSGI without its master process manager *** your memory page size is 4096 bytes detected max file descriptor number: 1048576 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** The -s/--socket option is missing and stdin is not a socket.

    Any idea? Thanks :)

    opened by LucaNerlich 3
  • Getting an error on a fresh install

    Getting an error on a fresh install

    I'm getting following error after executing docker run -d --restart=always --name nginxui -v /etc/nginx:/etc/nginx -p 8080:8080 schenkd/nginx-ui:latest:

    [2020-07-13 13:53:52,503] ERROR in app: Exception on /api/domains [GET]
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
        response = self.full_dispatch_request()
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
        rv = self.handle_user_exception(e)
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
        reraise(exc_type, exc_value, tb)
      File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
        raise value
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
        rv = self.dispatch_request()
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
        return self.view_functions[rule.endpoint](**req.view_args)
      File "./app/api/endpoints.py", line 60, in get_domains
        for _ in os.listdir(config_path):
    FileNotFoundError: [Errno 2] No such file or directory: '/etc/nginx/conf.d'
    

    I obv do have nginx installed and that dir exists. I also tried changing the permissions but the problem persists. I feel like I'm making a dumb mistake here :P

    opened by bkhanale 2
  • [Suggestion] Implement nginxconfig.io

    [Suggestion] Implement nginxconfig.io

    Hey guys, just thought it would be cool to have a section that would integrate into this application which would expose the DigitalOcean's Nginx config "generator". I'm assuming that the "target audience" might really appreciate that. https://github.com/digitalocean/nginxconfig.io Curious what you guys think!

    duplicate 
    opened by flying-sausages 2
  • Support openresty

    Support openresty

    Can you add support for openresty too ? The only different between openresty and nginx is the name when run the command.

    Reload: nginx: systemctl reload nginx openresty: systemctl reload openresty

    Check config: nginx: nginx -t openresty: openresty -t

    question 
    opened by hong-duc 1
  • Support for arm64?

    Support for arm64?

    WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested.

    Can you somehow add support for arm64?

    opened by HalfdanDK 0
  • Nginx template fix and reloading on domain update, delete or disable

    Nginx template fix and reloading on domain update, delete or disable

    I fixed the template, as there was missing 'server' before the start of the template and comma error line. Also, using default logs path instead of nginx's log dir.

    opened by akay25 0
  • Docker security

    Docker security

    Hi, i have deployed nginx-ui on Docker like documentation but i have a problem: if I try to access to nginx-ui through nginx proxy all is ok (basic auth ask me login) but if i go direct on port 8080 then i can access to nginx-ui bypassing nginx proxy. So, this is a summary: nginx.mysite.com -> asking login (OK!!!) mysite.com:8080 -> i can access to nginx-ui without login.

    Any helps? NGINX config

    server { 
     listen 80;
     server_name nginx.mysite.com; 
     return 301 https://$host$request_uri; 
    } 
    server {
        listen 443 ssl; 
        server_name nginx.mysite.com; 
        ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; 
        ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; 
        include /etc/letsencrypt/options-ssl-nginx.conf; 
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    
        location / {
            proxy_pass http://127.0.0.1:8080/;
        }
    
        auth_basic "nginxui secured";
        auth_basic_user_file /etc/apache2/.htpasswd;
    }
    
    opened by matteoventuri7 1
  • Is there a binary release available? I need to integrate it with

    Is there a binary release available? I need to integrate it with

    Is there a binary release (without a container) available? I need a binary version so that I can integrate it with my VPS Bootstrapper (a GUI VPS control panel that runs on Windows desktop, Free edition available), and I don't think it's possible with a container...

    To help you understand my question, I'm posting a screen of this GUI tool below, basically I want to let the user click a button to install nginx-ui (with authentication set) so that other users can also edit the nginx configurations through the web.

    nginx-website-setup-1076x694

    Thanks.

    opened by edwinyzh 0
  • Generated domain conf template is invalid - missing server

    Generated domain conf template is invalid - missing server

    2021/03/22 12:13:33 [emerg] 1#1: unexpected "{" in /etc/nginx/conf.d/testdomain.conf:1
    nginx: [emerg] unexpected "{" in /etc/nginx/conf.d/testdomain.conf:1
    

    It should include the `server {

    }` Which is missing from the template.

    opened by Ketec 1
Releases(v0.2)
  • v0.2(Jun 28, 2020)

    This version is the MVP of the nginx ui. features that are included in this release:

    • Automatic reading of configuration files as long as they are not in a nested structure.
    • Creation of new domains and the possibility to enable and disable them.
    • Documentation on securing Nginx UI
    • Responsive UI which can also be used on a tablet and mobile phone.
    Source code(tar.gz)
    Source code(zip)
Owner
David Schenk
start small. stay tuned.
David Schenk
A new style for Django admin

Djamin Djamin a new and clean styles for Django admin based in Google projects styles. Quick start Install djamin: pip install -e git://github.com/her

Herson Leite 236 Dec 15, 2022
An administration website for Django

yawd-admin, a django administration website yawd-admin now has a live demo at http://yawd-admin.yawd.eu/. Use demo / demo as username & passowrd. yawd

Pantelis Petridis 140 Oct 30, 2021
A new style for Django admin

Djamin Djamin a new and clean styles for Django admin based in Google projects styles. Quick start Install djamin: pip install -e git://github.com/her

Herson Leite 236 Dec 15, 2022
Disable dark mode in Django admin user interface in Django 3.2.x.

Django Non Dark Admin Disable or enable dark mode user interface in Django admin panel (Django==3.2). Installation For install this app run in termina

Artem Galichkin 6 Nov 23, 2022
A configurable set of panels that display various debug information about the current request/response.

Django Debug Toolbar The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/respons

Jazzband 7.3k Dec 31, 2022
aiohttp admin is generator for admin interface based on aiohttp

aiohttp admin is generator for admin interface based on aiohttp

Mykhailo Havelia 17 Nov 16, 2022
Simple and extensible administrative interface framework for Flask

Flask-Admin The project was recently moved into its own organization. Please update your references to Flask-Admin 5.2k Dec 29, 2022

Real-time monitor and web admin for Celery distributed task queue

Flower Flower is a web based tool for monitoring and administrating Celery clusters. Features Real-time monitoring using Celery Events Task progress a

Mher Movsisyan 5.5k Dec 28, 2022
A Django app for easily adding object tools in the Django admin

Django Object Actions If you've ever tried making admin object tools you may have thought, "why can't this be as easy as making Django Admin Actions?"

Chris Chang 524 Dec 26, 2022
StyleCLIP: Text-Driven Manipulation of StyleGAN Imagery

StyleCLIP: Text-Driven Manipulation of StyleGAN Imagery

3.3k Jan 01, 2023
Jinja is a fast, expressive, extensible templating engine.

Jinja is a fast, expressive, extensible templating engine. Special placeholders in the template allow writing code similar to Python syntax.

The Pallets Projects 9k Jan 04, 2023
Allow foreign key attributes in list_display with '__'

django-related-admin Allow foreign key attributes in Django admin change list list_display with '__' This is based on DjangoSnippet 2996 which was mad

Petr Dlouhý 62 Nov 18, 2022
fastapi-admin is a fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin.

fastapi-admin is a fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin.

fastapi-admin 1.6k Dec 30, 2022
GFPGAN is a blind face restoration algorithm towards real-world face images.

GFPGAN is a blind face restoration algorithm towards real-world face images.

Applied Research Center (ARC), Tencent PCG 25.6k Jan 04, 2023
A python application for manipulating pandas data frames from the comfort of your web browser

A python application for manipulating pandas data frames from the comfort of your web browser. Data flows are represented as a Directed Acyclic Graph, and nodes can be ran individually as the user se

Schlerp 161 Jan 04, 2023
Extends the Django Admin to include a extensible dashboard and navigation menu

django-admin-tools django-admin-tools is a collection of extensions/tools for the default django administration interface, it includes: a full feature

Django Admin Tools 731 Dec 28, 2022
A flat theme for Django admin interface. Modern, fresh, simple.

Django Flat Theme django-flat-theme is included as part of Django from version 1.9! 🎉 Please use this app if your project is powered by an older Djan

elky 416 Sep 22, 2022
Python Crypto Bot

Python Crypto Bot

Michael Whittle 1.6k Jan 06, 2023
Jazzy theme for Django

Django jazzmin (Jazzy Admin) Drop-in theme for django admin, that utilises AdminLTE 3 & Bootstrap 4 to make yo' admin look jazzy Installation pip inst

David Farrington 1.2k Jan 08, 2023
Django Smuggler is a pluggable application for Django Web Framework that helps you to import/export fixtures via the automatically-generated administration interface.

Django Smuggler Django Smuggler is a pluggable application for Django Web Framework to easily dump/load fixtures via the automatically-generated admin

semente 373 Dec 26, 2022