nginxconf

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: Apache-2.0 Imports: 29 Imported by: 1

README

Caddy NGINX Config Adapter

This is a config adapter for Caddy which converts NGINX config files into Caddy's native format.

This project is not complete, and we are asking the community to help finish its development. Due to resource constraints, we are unable to do all the development on our own at this time. However, we hope you will pick it up and collaborate on it together as a community. We'll be happy to coordinate efforts from the community. Start by opening issues and pull requests, then reviewing pull requests and testing changes!

Currently supported directives per context:

  • main:
    • http
  • http:
    • server
    • index
    • upstream
  • server:
    • listen
    • server_name
    • location
    • root
    • index
    • access_log
    • rewrite
    • if
  • if:
    • break
    • return
    • rewrite
    • set
  • upstream:
    • server
    • hash
    • ip_hash
    • keepalive
    • keepalive_requests
    • keepalive_timeout
    • ntlm
    • least_conn
    • random
  • location:
    • location
    • if
    • root
    • add_header
    • deny
    • allow
    • rewrite
    • fastcgi_pass
    • proxy_pass
    • expires
    • return
  • if (in location):
    • root
    • gzip
    • add_header
    • expires
    • proxy_pass

Thank you, and we hope you have fun with it!

Install

First, ensure your GOROOT and GOPATH environment variables are correct for your environment.

Then, follow the xcaddy install process here.

Then, build Caddy with this Go module plugged in. For example:

$ xcaddy build --with github.com/caddyserver/nginx-adapter

Use

Using this config adapter is the same as all the other config adapters.

You can also run Caddy directly with an nginx config using caddy run|start --config nginx.conf --adapter nginx (however, we do not recommend this until the config adapter is completed, since unfinished directives may just result in warnings and not errors).

Disclaimer

This project is not affiliated with F5 Networks or NGINX, Inc. NGINX is a registered trademark of NGINX, Inc.

Documentation

Index

Constants

View Source
const ErrExpiresAtTime = "usage of `expires @time` is not supported"
View Source
const ErrNamedLocation = "named locations marked by @ are unnsupported"
View Source
const ErrUnrecognized = "unrecognized or unsupported nginx directive"

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct{}

Adapter adapts NGINX config to Caddy JSON.

func (Adapter) Adapt

func (Adapter) Adapt(body []byte, options map[string]interface{}) ([]byte, []caddyconfig.Warning, error)

Adapt converts the NGINX config in body to Caddy JSON.

type Directive

type Directive struct {
	// Params contains the name and parameters on
	// the line. The first element is the name.
	Params []string

	// Block contains the block contents, if present.
	Block []Directive

	File string

	Line int
}

Directive represents an nginx configuration directive.

func (Directive) Name

func (d Directive) Name() string

Name returns the value of the first parameter.

func (Directive) Param

func (d Directive) Param(idx int) string

Param returns the parameter at position idx.

type Upstream

type Upstream struct {
	Servers         reverseproxy.UpstreamPool
	NTLM            bool
	SelectionPolicy struct {
		Name     string
		Selector reverseproxy.Selector
	}
	KeepAlive *reverseproxy.KeepAlive
}

Jump to

Keyboard shortcuts

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