https://github.com/soulteary/nginx-formatter
Small and easy-to-use Nginx configuration formatting tool (CLI & GUI), support Docker, x86, ARM, macOS...
https://github.com/soulteary/nginx-formatter
docker nginx nginx-conf nginx-configuration nginx-docker nginx-formatter
Last synced: 6 days ago
JSON representation
Small and easy-to-use Nginx configuration formatting tool (CLI & GUI), support Docker, x86, ARM, macOS...
- Host: GitHub
- URL: https://github.com/soulteary/nginx-formatter
- Owner: soulteary
- License: apache-2.0
- Created: 2023-04-18T13:36:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-01T20:34:16.000Z (almost 2 years ago)
- Last Synced: 2025-03-31T02:41:14.074Z (about 1 month ago)
- Topics: docker, nginx, nginx-conf, nginx-configuration, nginx-docker, nginx-formatter
- Language: Go
- Homepage: https://soulteary.com/2023/05/20/code-writing-practice-supported-by-ai-quickly-implement-nginx-configuration-formatting-tool.html
- Size: 465 KB
- Stars: 57
- Watchers: 1
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Nginx Formatter
[](https://github.com/soulteary/nginx-formatter/actions/workflows/github-code-scanning/codeql) [](https://github.com/soulteary/nginx-formatter/actions/workflows/codecov.yml) [](https://github.com/soulteary/nginx-formatter/actions/workflows/scan.yml) [](https://github.com/soulteary/nginx-formatter/actions/workflows/release.yaml)  [](https://hub.docker.com/r/soulteary/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](https://github.com/soulteary/nginx-formatter/releases).
If you use docker, you can use the following command ([DockerHub](https://hub.docker.com/r/soulteary/nginx-formatter)):
```bash
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:
```bash
./nginx-formatter
```### Common Usage (CLI & WebUI)
Use different indentation symbols (You can use spaces, tabs, ` `, `\s`, `\t`) and indentation amounts:
```bash
./nginx-formatter -indent=4 -char=" "
```### CLI Usage
Format the configuration file in the specified directory:
```bash
./nginx-formatter -input=./your-dir-path
```Format a file somewhere and save it in a new directory:
```bash
./nginx-formatter -input=./your-dir-path -output=./your-output-dir
```### WebUI Usage
Start the web interface:
```bash
./nginx-formatter -web
```specified the port:
```bash
./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:
```bash
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:
```bash
docker run --rm -it -v `pwd`:/app soulteary/nginx-formatter:v1.1.1 -input=/app
```## Full parameters supported
List of parameters supported:
```bash
Nginx FormatterUsage 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
- https://github.com/1connect/nginx-config-formatter (https://github.com/slomkowski/nginx-config-formatter)
- Yosef Ported the JavaScript beautifier under [Apache-2.0 license], 24/08/2016
- https://github.com/vasilevich/nginxbeautifier
- 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-formatterRuntime dependent Components
- ECMAScript 5.1(+) implementation in Go, under [MIT license].
- https://github.com/dop251/gojaWeb Components
- Gin is a HTTP web framework written in Go (Golang), under [MIT license].
- https://github.com/gin-gonic/gin
- Code Mirror, in-browser code editor, under [MIT license].
- https://github.com/codemirror/codemirror5