# README
Nginx Formatter

Nginx configuration formatter ~10MB size, support CLI, WebUI, x86, ARM, Linux, macOS.

Download
Download the binaries for your system and architecture from the releases page.

If you use docker, you can use the following command (DockerHub):
docker pull soulteary/nginx-formatter:latest
docker pull soulteary/nginx-formatter:v1.1.1
Usage
Use default parameters to format all configuration files in the current directory:
./nginx-formatter
Common Usage (CLI & WebUI)
Use different indentation symbols (You can use spaces, tabs,
, \s
, \t
) and indentation amounts:
./nginx-formatter -indent=4 -char=" "
CLI Usage
Format the configuration file in the specified directory:
./nginx-formatter -input=./your-dir-path
Format a file somewhere and save it in a new directory:
./nginx-formatter -input=./your-dir-path -output=./your-output-dir
WebUI Usage
Start the web interface:
./nginx-formatter -web
specified the port:
./nginx-formatter -web -port=8123
Docker Usage
There is no difference between using parameters in Docker and the above, for example, we start a Web UI formatting tool service in Docker:
docker run --rm -it -p 8080:8080 soulteary/nginx-formatter:v1.1.1 -web
If you want to format the configuration of the current directory, you can use the program in Docker with a command similar to the following:
docker run --rm -it -v `pwd`:/app soulteary/nginx-formatter:v1.1.1 -input=/app
Full parameters supported
List of parameters supported:
Nginx Formatter
Usage of ./nginx-formatter:
-char
Indent char, defualt: (default " ")
-indent int
Indent size, defualt: 2 (default 2)
-input string
Input directory
-output string
Output directory
-port 8080
WebUI Port, defualt: 8080 (default 8080)
-web false
Enable WebUI, defualt: false
Credits
Formatter Components
- Slomkowski Created a beautifier for nginx config files with Python under [Apache-2.0 license], 24/06/2016
- Yosef Ported the JavaScript beautifier under [Apache-2.0 license], 24/08/2016
- soulteary Modify the JavaScript version for golang execution, under [Apache-2.0 license], 18/04/2023:
- simplify the program, fix bugs, improve running speed, and allow running in golang
- https://github.com/soulteary/nginx-formatter
Runtime dependent Components
- ECMAScript 5.1(+) implementation in Go, under [MIT license].
Web Components
- Gin is a HTTP web framework written in Go (Golang), under [MIT license].
- Code Mirror, in-browser code editor, under [MIT license].