Giter Site home page Giter Site logo

soulteary / nginx-formatter Goto Github PK

View Code? Open in Web Editor NEW
45.0 1.0 5.0 476 KB

Small and easy-to-use Nginx configuration formatting tool (CLI & GUI), support Docker, x86, ARM, macOS...

Home Page: https://soulteary.com/2023/05/20/code-writing-practice-supported-by-ai-quickly-implement-nginx-configuration-formatting-tool.html

License: Apache License 2.0

Go 56.87% JavaScript 28.15% Dockerfile 3.64% HTML 11.35%
docker nginx nginx-conf nginx-configuration nginx-docker nginx-formatter

nginx-formatter's Introduction

Nginx Formatter

CodeQL Codecov Security Scan Release Go Report Card Docker Image

ENGLISH | 中文文档

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

Runtime dependent Components

Web Components

nginx-formatter's People

Contributors

soulteary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nginx-formatter's Issues

The escape character will be lost

I executed . /nginx-formatter in the config file directory

        if ($http_user_agent ~ (Edg|Sogou\ web|Semrushbot|Scrapy|Curl)) {
            return 403; }
            }

After formatting it will become

    if ($http_user_agent ~ (Edg|Sogou web|Semrushbot|Scrapy|Curl)) {
      return 403; }
    }

json format error

I use webui by docker and get wrong code:

input:

    location /api/ro {
      default_type "application/json";
      return ' { "code":200 }'
}

output:

location /api/ro {
      default_type "application/json";
      return ' {
        #$#%#$#placeholder03434#$#%#$#:200
      }
      '
    }

Changes code

It changes code like:

return 200 ''; -> return 200 "''";
return 200 ""; -> return 200 """";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.