NginxWebUI--A powerful nginx visual configuration tool

foreword

This article introduces NginxWebUI, through this tool, we can easily configure our various functions in a graphical way Nginx, including HTTPprotocol forwarding, TCPprotocol forwarding, reverse proxy, load balancing, SSLautomatic certificate application and renewal. NginxWebUIIt can be deployed on various platforms such as Ubuntu, , CentOS, Windowsetc., and can be deployed locally or through Docker images. The Dockerdeployment is the easiest. You only need to pull the image, create and start the container. Next, we will demonstrate how to use Dockerit to deploy NginxWebUI.

NginxWebUI official website
Official website

environment

System: CentOS 7
Docker: 20.10.11

pull image

docker pull cym1102/nginxwebui:latest

insert image description here

Create and start the container

You can customize the mapping directory between the nginxWebUI container and the host according to your own habits

This command to create a container uses the --net=hostdirect mapping of the local port, because the internal nginx may use any port, so all ports of the local machine must be mapped.

docker run -d -v /mydata/nginxWebUI:/home/nginxWebUI -e BOOT_OPTIONS="--server.port=8080" --privileged=true --net=host cym1102/nginxwebui:latest

But I usually only use port 80 and port 443, and nginxWebUI also uses port 8080. Here I use port mapping to monitor:-p 80:80 -p 443:443 -p 8080:8080

Custom port mapping will have limitations. If you proxy to other ports in the configuration, you will not be able to listen. So if you want to listen to the port at will, please use the above command. If you only get 80 and 443 like me, then Please use the following command

docker run -itd -v /mydata/nginxWebUI:/home/nginxWebUI -e BOOT_OPTIONS="--server.port=8080" --privileged=true -p 80:80 -p 443:443 -p 8080:8080 cym1102/nginxwebui:latest /bin/bash


Notice:

  • The container needs to map the path /mydata/nginxWebUI:/home/nginxWebUI. This path stores all data files of the project, including databases, nginx configuration files, logs, certificates, etc. When upgrading the image, this directory can ensure that the project data will not be lost. Please note backup.

  • -e BOOT_OPTIONS parameter can be filled with java startup parameters, you can use this parameter to modify the port number, "--server.

  • The log is stored in /mydata/nginxWebUI/log/nginxWebUI.log by default

View containers

docker ps

The container starts normally

Access backend management

Since my container port parameter --server.port=8080is set to 8080 when creating the container, we need to use the server IP+8080 port to access the background.

For example, my server IP: 192.168.223.140, then I will visit 192.168.223.140:8080, and I will enter the following interface. When entering the background for the first time, you need to set the user name and password:
insert image description here
after setting the user name and password, you can log in directly:
insert image description here
here we successfully log in to the background:
insert image description here
locally You can configure Nginx basic parameters, http parameters, Stream parameters, reverse proxy (server) parameters, and load balancing.

For example: here demonstrates the configuration of the reverse proxy (server) parameters

Proxy server port 80 to server port 8080 for testing
insert image description here

Submit configuration

launch configuration

On the left is the generated nginx configuration, and on the right is the real configuration file of nginx

replace file

For our configuration to take effect, we need to replace the generated nginx configuration with the real nginx configuration file, which is very simple here, just clickreplace fileIt can be replaced, and the original file configuration will be automatically backed up after the replacement.

There are various startup schemes for starting Nginx

. If the startup fails, you can switch to other schemes. There are also various schemes for stopping nginx, which will not be demonstrated here.

Test configuration

Above we proxy port 80 to port 8080, so that our access to port 80 will go directly to the background of nginxWebUI.

By default, the browser access http protocol is port 80, which can be added here. It is added here for intuitive display.
Effect:
insert image description here
You can see that our configuration file takes effect, and access to port 80 is proxied to port 8080 of the server.

At last

Only shown hereReverse proxy function, the use of other functions is almost the same, you can test it yourself.

The functions of nginx itself are complex. This project does not cover all the functions of nginx. It can only configure common functions. More advanced function configurations still need to be manually written in the final generated nginx.conf.

The end of the tutorial~

Guess you like

Origin blog.csdn.net/qq_31762741/article/details/122489344