nginxconf

package
v1.5.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nginxconf converts nginx configuration text into config file documents. It only reads text.

Index

Constants

View Source
const (
	StatusMapped      = "mapped"
	StatusPartial     = "partial"
	StatusUnsupported = "unsupported"
)

Report row statuses.

View Source
const DefaultPrefix = "/etc/nginx"

DefaultPrefix is where absolute include paths usually point; it is remapped onto the import root.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name string
	Data []byte
}

File is one generated document.

type Limits

type Limits struct {
	MaxBytes        int
	MaxFiles        int
	MaxIncludeDepth int
	MaxBlockDepth   int
}

Limits bound what a hostile or oversized configuration can cost.

func LimitsFromEnv

func LimitsFromEnv(lookup func(string) (string, bool)) Limits

LimitsFromEnv reads the caps, keeping the default for unset or non positive values.

type Options

type Options struct {
	Limits Limits
	// Prefix is the absolute directory nginx loaded its files from.
	Prefix string
	// Apps overrides the app for a host name, upstream name or upstream address.
	Apps map[string]string
	// Valid reports whether a generated document passes file validation; nil refuses all.
	Valid func(name string, data []byte) bool
	// MaxHeaderRules caps header rules per host.
	MaxHeaderRules int
}

Options controls one import.

type Report

type Report struct {
	Rows     []Row    `json:"rows"`
	Warnings []string `json:"warnings,omitempty"`
}

Report lists every directive read, plus warnings that deserve a look before applying.

func (Report) Counts

func (r Report) Counts() map[string]int

Counts returns how many rows hold each status.

func (Report) Markdown

func (r Report) Markdown() string

Markdown renders the report as a table.

func (Report) Summary

func (r Report) Summary() string

Summary is the one line count.

type Result

type Result struct {
	Files  []File
	Report Report
}

Result is the generated documents and the per directive report.

func Import

func Import(target string, opts Options) (*Result, error)

Import reads a configuration file or directory and converts it.

type Row

type Row struct {
	File      string `json:"file"`
	Line      int    `json:"line"`
	Directive string `json:"directive"`
	Status    string `json:"status"`
	Target    string `json:"target,omitempty"`
	Note      string `json:"note,omitempty"`
}

Row is the fate of one directive. It never carries argument values, which may be secrets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL