Git Product home page Git Product logo

nginx-adapter's People

Contributors

mholt avatar mohammed90 avatar tjhowse 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nginx-adapter's Issues

Are upstream directives supported?

I'm getting an error with upstream directives:

[WARNING][nginx] nginx.conf:11: upstream: unrecognized or unsupported nginx directive

The README suggests that they're supported, but they aren't included in the supported directives under the http context.

Are upstream directives supported?

nginx server: unrecognized or unsupported nginx directive

Basic directives like server are reported as unrecognized.

Here is my nginx config (it's a symfony 3.4 app).

server {
    server_name uat.gpsc.cwtwebpem.com;
    root /srv/app/web;

    location / {
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }

    location ~ ^/(app)\.php(/|$) {
        fastcgi_pass php-upstream;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        # include fastcgi_params;
        # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # fastcgi_param HTTPS off;
    }

}

I am calling the adpater like so:

caddy adapt --config /etc/caddy/nginx.conf --adapter nginx --pretty --validate

Here si the result:

{
        "apps": {
                "http": {}
        }
}
2023/06/06 08:19:08.387 WARN    nginx   server: unrecognized or unsupported nginx directive     {"file": "/etc/caddy/nginx.conf", "line": 1}

Converting the nginx.conf panics

Hi @mholt, thank you for Caddy and especially for writing this adapter.

Trying to run the adapter with the latest beta.20 panics now with following error:

Error logs

./caddy adapt --config nginx.conf --adapter nginx
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/caddyserver/caddy/v2/caddyconfig.JSONModuleObject(0x13fabc0, 0x0, 0x15a1eb5, 0x7, 0x15a8319, 0x8, 0xc0007ce228, 0x1, 0x1357120, 0x1)
	github.com/caddyserver/caddy/[email protected]/caddyconfig/configadapters.go:83 +0x441
github.com/caddyserver/nginx-adapter.(*setupState).locationContext(0xc0007cf968, 0xc0006f3110, 0xc0006146e0, 0x1, 0x1, 0xc000193a20, 0x1, 0x2, 0x27, 0x30, ...)
	github.com/caddyserver/[email protected]/location.go:125 +0x3e43
github.com/caddyserver/nginx-adapter.(*setupState).serverContext(0xc0007cf968, 0xc0000e6b40, 0x5, 0x8, 0xc0007cf520, 0x1, 0x1, 0x1, 0x2)
	github.com/caddyserver/[email protected]/server.go:110 +0x1efd
github.com/caddyserver/nginx-adapter.(*setupState).httpContext(0xc0007cf968, 0xc00023cd80, 0xb, 0x10, 0xc0007cf730, 0x1, 0x1, 0x1, 0x127da31)
	github.com/caddyserver/[email protected]/nginxadapter.go:113 +0x4d4
github.com/caddyserver/nginx-adapter.(*setupState).mainContext(0xc0007cf968, 0xc0000e6480, 0x7, 0x8, 0x0, 0x0, 0xc00005e800, 0xc0007cf908, 0x43daec)
	github.com/caddyserver/[email protected]/nginxadapter.go:87 +0x4cb
github.com/caddyserver/nginx-adapter.Adapter.Adapt(0xc0003c8a80, 0x774, 0x974, 0xc0006f29c0, 0xc00062e900, 0x1500000001516640, 0xc0007cfbc8, 0x159c3be7505eb59e, 0x10, 0x1356f20, ...)
	github.com/caddyserver/[email protected]/nginxadapter.go:51 +0x1f6
github.com/caddyserver/caddy/v2/cmd.cmdAdaptConfig(0xc00018c9c0, 0xc0000d0140, 0x4, 0x4)
	github.com/caddyserver/caddy/[email protected]/cmd/commandfuncs.go:464 +0x3ed
github.com/caddyserver/caddy/v2/cmd.Main()
	github.com/caddyserver/caddy/[email protected]/cmd/main.go:84 +0x23e
main.main()
	caddy/main.go:12 +0x20

Steps to reproduce:

go get github.com/caddyserver/builder/cmd/xcaddy

xcaddy build v2.0.0-beta.20 --with github.com/caddyserver/nginx-adapter@0464b93dab75db7fc111ad558d29615832b84f7f

curl https://raw.githubusercontent.com/caddyserver/nginx-adapter/master/testdata/example1.conf -o nginx.conf

./caddy adapt --config nginx.conf --adapter nginx

Edit: Updated the logs

Unrecognized Config Adapter

Hi,

Caddy is not recognizing the adapter. I have done go get github.com/caddyserver/nginx-adapter, went to nginx-adapter, and done go build, according to the instructions, yet it's still not recognized when I do root@dynmc:~# caddy run --config Caddyfile --adapter nginx 2020/02/22 16:00:25.857 INFO using provided configuration {"config_file": "Caddyfile", "config_adapter": "nginx"} run: unrecognized config adapter: nginx root@dynmc:~# caddy run --config Caddyfile --adapter nginx.

Thank you.

Error when building Caddy with nginx-adapter

I'm getting the following error when building caddy with nginx-adapter.

Click to expand!

=> ERROR [builder 2/2] RUN xcaddy build --with github.com/caddyserver/nginx-adapter 339.0s

[builder 2/2] RUN xcaddy build --with github.com/caddyserver/nginx-adapter:
#0 0.245 2022/07/17 11:10:44 [INFO] Temporary folder: /tmp/buildenv_2022-07-17-1110.2147504725
#0 0.246 2022/07/17 11:10:44 [INFO] Writing main module: /tmp/buildenv_2022-07-17-1110.2147504725/main.go
#0 0.246 package main
#0 0.246
#0 0.246 import (
#0 0.246 caddycmd "github.com/caddyserver/caddy/v2/cmd"
#0 0.246
#0 0.246 // plug in Caddy modules here
#0 0.246 _ "github.com/caddyserver/caddy/v2/modules/standard"
#0 0.246 _ "github.com/caddyserver/nginx-adapter"
#0 0.246 )
#0 0.246
#0 0.246 func main() {
#0 0.246 caddycmd.Main()
#0 0.246 }
#0 0.247 2022/07/17 11:10:44 [INFO] Initializing Go module
#0 0.248 2022/07/17 11:10:44 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
#0 0.348 go: creating new go.mod: module caddy
#0 0.362 go: to add module requirements and sums:
#0 0.362 go mod tidy
#0 0.366 2022/07/17 11:10:44 [INFO] Pinning versions
#0 0.367 2022/07/17 11:10:44 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
#0 0.753 go: downloading github.com/caddyserver/caddy/v2 v2.5.2
#0 3.482 go: downloading github.com/caddyserver/certmagic v0.16.1
#0 3.482 go: downloading github.com/google/uuid v1.3.0
#0 3.483 go: downloading github.com/lucas-clemente/quic-go v0.28.0
#0 3.589 go: downloading github.com/prometheus/client_golang v1.12.1
#0 3.817 go: downloading go.uber.org/zap v1.21.0
#0 3.969 go: downloading golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
#0 4.081 go: downloading github.com/klauspost/cpuid/v2 v2.0.13
#0 4.083 go: downloading github.com/libdns/libdns v0.2.1
#0 4.086 go: downloading github.com/mholt/acmez v1.0.2
#0 4.204 go: downloading github.com/miekg/dns v1.1.46
#0 4.245 go: downloading golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2
#0 4.247 go: downloading golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e
#0 4.315 go: downloading github.com/beorn7/perks v1.0.1
#0 4.425 go: downloading github.com/cespare/xxhash/v2 v2.1.2
#0 4.499 go: downloading github.com/golang/protobuf v1.5.2
#0 4.500 go: downloading github.com/cespare/xxhash v1.1.0
#0 4.578 go: downloading github.com/prometheus/client_model v0.2.0
#0 4.646 go: downloading github.com/prometheus/common v0.32.1
#0 4.872 go: downloading github.com/prometheus/procfs v0.7.3
#0 4.872 go: downloading golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
#0 5.007 go: downloading google.golang.org/protobuf v1.28.0
#0 5.165 go: downloading github.com/marten-seemann/qpack v0.2.1
#0 5.301 go: downloading github.com/cheekybits/genny v1.0.0
#0 5.532 go: downloading github.com/onsi/ginkgo v1.16.4
#0 5.916 go: downloading go.uber.org/atomic v1.9.0
#0 5.918 go: downloading go.uber.org/multierr v1.6.0
#0 5.937 go: downloading golang.org/x/tools v0.1.7
#0 5.961 go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
#0 6.021 go: downloading github.com/marten-seemann/qtls-go1-16 v0.1.5
#0 6.094 go: downloading github.com/marten-seemann/qtls-go1-17 v0.1.2
#0 6.148 go: downloading github.com/marten-seemann/qtls-go1-18 v0.1.2
#0 6.573 go: downloading github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1
#0 6.607 go: downloading golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b
#0 7.821 go: downloading github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
#0 7.973 go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
#0 8.084 go: downloading golang.org/x/mod v0.4.2
#0 8.202 go: downloading github.com/nxadm/tail v1.4.8
#0 8.288 go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
#0 8.355 go: downloading github.com/fsnotify/fsnotify v1.5.1
#0 19.72 go: added github.com/beorn7/perks v1.0.1
#0 19.72 go: added github.com/caddyserver/caddy/v2 v2.5.2
#0 19.72 go: added github.com/caddyserver/certmagic v0.16.1
#0 19.72 go: added github.com/cespare/xxhash/v2 v2.1.2
#0 19.72 go: added github.com/cheekybits/genny v1.0.0
#0 19.72 go: added github.com/fsnotify/fsnotify v1.5.1
#0 19.72 go: added github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
#0 19.72 go: added github.com/golang/protobuf v1.5.2
#0 19.72 go: added github.com/google/uuid v1.3.0
#0 19.72 go: added github.com/klauspost/cpuid/v2 v2.0.13
#0 19.72 go: added github.com/libdns/libdns v0.2.1
#0 19.72 go: added github.com/lucas-clemente/quic-go v0.28.0
#0 19.72 go: added github.com/marten-seemann/qpack v0.2.1
#0 19.72 go: added github.com/marten-seemann/qtls-go1-16 v0.1.5
#0 19.72 go: added github.com/marten-seemann/qtls-go1-17 v0.1.2
#0 19.72 go: added github.com/marten-seemann/qtls-go1-18 v0.1.2
#0 19.72 go: added github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1
#0 19.72 go: added github.com/matttproud/golang_protobuf_extensions v1.0.1
#0 19.72 go: added github.com/mholt/acmez v1.0.2
#0 19.72 go: added github.com/miekg/dns v1.1.46
#0 19.72 go: added github.com/nxadm/tail v1.4.8
#0 19.72 go: added github.com/onsi/ginkgo v1.16.4
#0 19.72 go: added github.com/prometheus/client_golang v1.12.1
#0 19.72 go: added github.com/prometheus/client_model v0.2.0
#0 19.72 go: added github.com/prometheus/common v0.32.1
#0 19.72 go: added github.com/prometheus/procfs v0.7.3
#0 19.72 go: added go.uber.org/atomic v1.9.0
#0 19.72 go: added go.uber.org/multierr v1.6.0
#0 19.72 go: added go.uber.org/zap v1.21.0
#0 19.72 go: added golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2
#0 19.72 go: added golang.org/x/mod v0.4.2
#0 19.72 go: added golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e
#0 19.72 go: added golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
#0 19.72 go: added golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
#0 19.72 go: added golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b
#0 19.72 go: added golang.org/x/tools v0.1.7
#0 19.72 go: added golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
#0 19.72 go: added google.golang.org/protobuf v1.28.0
#0 19.72 go: added gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
#0 19.73 2022/07/17 11:11:03 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/nginx-adapter github.com/caddyserver/caddy/[email protected]
#0 20.38 go: downloading github.com/caddyserver/nginx-adapter v0.0.4
#0 29.86 go: downloading github.com/caddyserver/ntlm-transport v0.1.1
#0 29.86 go: downloading github.com/hairyhenderson/go-which v0.2.0
#0 29.93 go: downloading github.com/klauspost/compress v1.15.6
#0 29.93 go: downloading github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
#0 29.93 go: downloading github.com/google/cel-go v0.11.4
#0 30.25 go: downloading google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21
#0 30.28 go: downloading github.com/spf13/afero v1.3.3
#0 30.44 go: downloading github.com/BurntSushi/toml v1.1.0
#0 30.44 go: downloading github.com/Masterminds/sprig/v3 v3.2.2
#0 30.56 go: downloading github.com/alecthomas/chroma v0.10.0
#0 30.69 go: downloading github.com/yuin/goldmark v1.4.12
#0 30.93 go: downloading github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594
#0 31.04 go: downloading gopkg.in/yaml.v3 v3.0.1
#0 31.15 go: downloading github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b
#0 31.25 go: downloading github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed
#0 31.28 go: downloading github.com/smallstep/certificates v0.19.0
#0 31.41 go: downloading github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f
#0 32.99 go: downloading github.com/tailscale/tscert v0.0.0-20220316030059-54bbcb9f74e2
#0 33.10 go: downloading github.com/stoewer/go-strcase v1.2.0
#0 33.99 go: downloading github.com/smallstep/cli v0.18.0
#0 34.00 go: downloading github.com/smallstep/truststore v0.11.0
#0 34.00 go: downloading github.com/Masterminds/goutils v1.1.1
#0 34.06 go: downloading github.com/Masterminds/semver/v3 v3.1.1
#0 34.09 go: downloading github.com/huandu/xstrings v1.3.2
#0 34.19 go: downloading github.com/imdario/mergo v0.3.12
#0 34.23 go: downloading github.com/Masterminds/semver v1.4.2
#0 34.26 go: downloading github.com/mitchellh/copystructure v1.2.0
#0 34.30 go: downloading github.com/shopspring/decimal v1.2.0
#0 34.33 go: downloading github.com/spf13/cast v1.4.1
#0 34.44 go: downloading github.com/pkg/errors v0.9.1
#0 34.44 go: downloading github.com/smallstep/nosql v0.4.0
#0 34.55 go: downloading go.step.sm/cli-utils v0.7.0
#0 34.70 go: downloading go.step.sm/crypto v0.16.1
#0 34.94 go: downloading go.step.sm/linkedca v0.15.0
#0 34.94 go: downloading google.golang.org/grpc v1.46.0
#0 35.06 go: downloading gopkg.in/square/go-jose.v2 v2.6.0
#0 35.24 go: downloading github.com/slackhq/nebula v1.5.2
#0 35.67 go: downloading howett.net/plist v1.0.0
#0 35.79 go: downloading github.com/mitchellh/reflectwalk v1.0.2
#0 35.85 go: downloading github.com/dlclark/regexp2 v1.4.0
#0 35.94 go: downloading github.com/mitchellh/go-ps v1.0.0
#0 35.97 go: downloading github.com/micromdm/scep/v2 v2.1.0
#0 36.10 go: downloading go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352
#0 36.10 go: downloading github.com/urfave/cli v1.22.5
#0 36.21 go: downloading github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
#0 36.25 go: downloading github.com/manifoldco/promptui v0.9.0
#0 36.29 go: downloading filippo.io/edwards25519 v1.0.0-rc.1
#0 36.40 go: downloading github.com/dgraph-io/badger v1.6.2
#0 36.40 go: downloading github.com/dgraph-io/badger/v2 v2.2007.4
#0 36.64 go: downloading go.etcd.io/bbolt v1.3.6
#0 36.65 go: downloading github.com/go-sql-driver/mysql v1.6.0
#0 36.65 go: downloading github.com/jackc/pgx/v4 v4.14.0
#0 36.80 go: downloading github.com/go-kit/kit v0.10.0
#0 36.82 go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
#0 36.85 go: downloading github.com/cpuguy83/go-md2man v1.0.10
#0 37.05 go: downloading github.com/dgraph-io/ristretto v0.0.4-0.20200906165740-41ebdbffecfd
#0 37.25 go: downloading github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13
#0 37.25 go: downloading github.com/rs/xid v1.2.1
#0 37.27 go: downloading github.com/sirupsen/logrus v1.8.1
#0 37.35 go: downloading github.com/jackc/pgconn v1.10.1
#0 37.36 go: downloading github.com/jackc/pgtype v1.9.0
#0 37.46 go: downloading github.com/jackc/pgio v1.0.0
#0 37.50 go: downloading github.com/jackc/pgproto3/v2 v2.2.0
#0 37.61 go: downloading github.com/russross/blackfriday/v2 v2.0.1
#0 37.67 go: downloading github.com/russross/blackfriday v1.5.2
#0 37.67 go: downloading github.com/go-logfmt/logfmt v0.5.0
#0 37.72 go: downloading github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96
#0 37.75 go: downloading github.com/golang/snappy v0.0.4
#0 37.77 go: downloading github.com/jackc/chunkreader/v2 v2.0.1
#0 37.83 go: downloading github.com/jackc/pgpassfile v1.0.0
#0 37.84 go: downloading github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b
#0 37.87 go: downloading github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
#0 37.91 go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
#0 37.95 go: downloading github.com/mattn/go-colorable v0.1.8
#0 38.01 go: downloading github.com/mattn/go-isatty v0.0.13
#0 50.31 go: downloading github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220715204823-f1df3164ca2c
#0 50.32 go: downloading github.com/antlr/antlr4 v4.10.1+incompatible
#0 54.97 go: upgraded github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed => v0.0.0-20220715204823-f1df3164ca2c
#0 54.97 go: added github.com/caddyserver/nginx-adapter v0.0.4
#0 54.97 go: added github.com/caddyserver/ntlm-transport v0.1.1
#0 54.97 go: added github.com/hairyhenderson/go-which v0.2.0
#0 54.97 go: added github.com/spf13/afero v1.3.3
#0 54.98 2022/07/17 11:11:38 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v
#0 55.62 go: downloading github.com/go-chi/chi v4.1.2+incompatible
#0 55.64 go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
#0 55.69 go: downloading go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.29.0
#0 55.70 go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.4.0
#0 55.91 go: downloading go.opentelemetry.io/otel v1.4.0
#0 55.94 go: downloading go.opentelemetry.io/otel/sdk v1.4.0
#0 56.04 go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.4.0
#0 56.05 go: downloading go.opentelemetry.io/contrib v0.20.0
#0 56.11 go: downloading go.opentelemetry.io/otel/exporters/otlp v0.20.0
#0 56.23 go: downloading github.com/felixge/httpsnoop v1.0.2
#0 56.24 go: downloading go.opentelemetry.io/otel/metric v0.27.0
#0 56.24 go: downloading go.opentelemetry.io/otel/trace v1.4.0
#0 56.37 go: downloading go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.4.0
#0 56.37 go: downloading go.opentelemetry.io/proto/otlp v0.12.0
#0 56.43 go: downloading github.com/go-logr/logr v1.2.2
#0 56.43 go: downloading github.com/go-logr/stdr v1.2.2
#0 56.49 go: downloading go.opentelemetry.io/otel/internal/metric v0.27.0
#0 56.55 go: downloading github.com/cenkalti/backoff/v4 v4.1.2
#0 56.55 go: downloading github.com/grpc-ecosystem/grpc-gateway v1.16.0
#0 56.63 go: downloading github.com/cenkalti/backoff v2.2.1+incompatible
#0 58.54 2022/07/17 11:11:42 [INFO] Build environment ready
#0 58.54 2022/07/17 11:11:42 [INFO] Building Caddy
#0 58.54 2022/07/17 11:11:42 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
#0 59.12 go: downloading go.uber.org/goleak v1.1.12
#0 59.12 go: downloading github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262
#0 59.12 go: downloading github.com/stretchr/testify v1.7.1
#0 59.38 go: downloading github.com/google/go-cmp v0.5.7
#0 59.39 go: downloading gotest.tools/v3 v3.0.2
#0 59.45 go: downloading gopkg.in/yaml.v2 v2.4.0
#0 59.52 go: downloading github.com/golang/mock v1.6.0
#0 59.52 go: downloading github.com/onsi/gomega v1.13.0
#0 59.60 go: downloading gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
#0 59.69 go: downloading golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
#0 59.69 go: downloading github.com/benbjohnson/clock v1.1.0
#0 59.69 go: downloading github.com/davecgh/go-spew v1.1.1
#0 59.70 go: downloading github.com/pmezard/go-difflib v1.0.0
#0 59.78 go: downloading github.com/aws/aws-sdk-go v1.37.0
#0 69.78 go: downloading cloud.google.com/go/kms v1.4.0
#0 69.78 go: downloading github.com/googleapis/gax-go/v2 v2.1.1
#0 69.78 go: downloading google.golang.org/api v0.70.0
#0 69.78 go: downloading github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1
#0 69.83 go: downloading github.com/googleapis/gax-go v2.0.2+incompatible
#0 69.84 go: downloading github.com/kr/pretty v0.2.1
#0 69.85 go: downloading cloud.google.com/go v0.100.2
#0 69.92 go: downloading github.com/cockroachdb/apd v1.1.0
#0 69.93 go: downloading github.com/gofrs/uuid v4.0.0+incompatible
#0 70.12 go: downloading github.com/go-stack/stack v1.8.0
#0 70.16 go: downloading github.com/chzyer/logex v1.1.10
#0 70.22 go: downloading github.com/kr/text v0.2.0
#0 70.26 go: downloading github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65
#0 70.27 go: downloading github.com/lib/pq v1.10.2
#0 70.28 go: downloading github.com/jmespath/go-jmespath v0.4.0
#0 70.41 go: downloading github.com/OneOfOne/xxhash v1.2.2
#0 70.45 go: downloading github.com/spaolacci/murmur3 v1.1.0
#0 70.50 go: downloading cloud.google.com/go/iam v0.1.0
#0 82.06 go: downloading golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
#0 82.06 go: downloading cloud.google.com/go/compute v1.3.0
#0 82.06 go: downloading go.opencensus.io v0.23.0
#0 82.21 go: downloading google.golang.org/appengine v1.6.7
#0 82.38 go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
#0 82.69 2022/07/17 11:12:06 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath
#0 335.2 # github.com/caddyserver/ntlm-transport
#0 335.2 /go/pkg/mod/github.com/caddyserver/[email protected]/ntlm.go:111:18: n.HTTPTransport.SetScheme undefined (type *"github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy".HTTPTransport has no field or method SetScheme)
#0 338.7 2022/07/17 11:16:22 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2022-07-17-1110.2147504725
#0 338.7 2022/07/17 11:16:22 [FATAL] exit status 2


error: failed to solve: executor failed running [/bin/sh -c xcaddy build --with github.com/caddyserver/nginx-adapter]: exit code: 1

Dockerfile

FROM caddy:2.5.2-builder AS builder

RUN xcaddy build \
    --with github.com/caddyserver/nginx-adapter

FROM caddy:2.5.2

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Is it possible to convert nginx.conf into caddy.json?

This is the nginx file I was hoping to convert.

$ ./caddy adapt --config ~/nginx.conf --adapter nginx

{"apps":{"http":{}}}
2023/06/15 11:22:38.832	WARN	nginx	server: unrecognized or unsupported nginx directive	{"file": "/root/nginx.conf", "line": 2}
2023/06/15 11:22:38.832	WARN	nginx	server: unrecognized or unsupported nginx directive	{"file": "/root/nginx.conf", "line": 12}
2023/06/15 11:22:38.832	WARN	nginx	server: unrecognized or unsupported nginx directive	{"file": "/root/nginx.conf", "line": 26}

But it seems it's empty. It can't generate it. Is it because of the warnings?

Many Thanks,

Incompatible with Caddy 2.7.0-beta

Running xcaddy build v2.7.0-beta.2 --with github.com/caddyserver/nginx-adapter will not produce a successful build.

Logs:

2023/06/30 02:58:24 [INFO] exec (timeout=-2562047h47m16.854775808s): /usr/local/go/bin/go build -o /workspaces/nginx-adapter/caddy -ldflags -w -s -trimpath 
# github.com/caddyserver/nginx-adapter
/go/pkg/mod/github.com/caddyserver/[email protected]/server.go:231:4: unknown field WriterRaw in struct literal of type caddy.CustomLog
2023/06/30 02:59:14 [INFO] Cleaning up temporary folder: /tmp/buildenv_2023-06-30-0257.2300610627
2023/06/30 02:59:14 [FATAL] exit status 1

Handle "include" Directive

Currently (commit 00eef4c at the time of this writing), the adapter doesn't completely handle include directive. There's primitive support for the directive, which is why it is not documented as supported. Big part of the reason is due to difficulty in resolution of the absolute path of the file to be included. The resolution problem should be easy to solve now using the https://github.com/hairyhenderson/go-which project and manipulating the PATH env var within the scope of the adapter.

v2.4.0-beta.1: nginx-adapter fails to build using xcaddy

System:

  • Debian 11 (bullseye) amd64

Golang version:

go version go1.15.8 linux/amd64

Go env:

Go env

hnrk@host1:~$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hnrk/.cache/go-build"
GOENV="/home/hnrk/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/hnrk/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/hnrk/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/hnrk/go-bins/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/hnrk/go-bins/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build927830222=/tmp/go-build -gno-record-gcc-switches"

xcaddy version:

v0.1.8

Build command:

hnrk@host1:~$ xcaddy build v2.4.0-beta.1 --with github.com/caddyserver/nginx-adapter --with github.com/caddy-dns/cloudflare

Log:

2021/02/18 14:10:04 [INFO] Temporary folder: /tmp/buildenv_2021-02-18-1410.049791739
2021/02/18 14:10:04 [INFO] Writing main module: /tmp/buildenv_2021-02-18-1410.049791739/main.go
2021/02/18 14:10:04 [INFO] Initializing Go module
2021/02/18 14:10:04 [INFO] exec (timeout=10s): /home/hnrk/go-bins/go/bin/go mod init caddy
go: creating new go.mod: module caddy
2021/02/18 14:10:04 [INFO] Pinning versions
2021/02/18 14:10:04 [INFO] exec (timeout=0s): /home/hnrk/go-bins/go/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
2021/02/18 14:10:06 [INFO] exec (timeout=0s): /home/hnrk/go-bins/go/bin/go get -d -v github.com/caddyserver/nginx-adapter
go: github.com/caddyserver/nginx-adapter upgrade => v0.0.3
2021/02/18 14:10:07 [INFO] exec (timeout=0s): /home/hnrk/go-bins/go/bin/go get -d -v github.com/caddy-dns/cloudflare
go: github.com/caddy-dns/cloudflare upgrade => v0.0.0-20210105070211-eda8e5aa2223
2021/02/18 14:10:08 [INFO] Build environment ready
2021/02/18 14:10:08 [INFO] Building Caddy
2021/02/18 14:10:08 [INFO] exec (timeout=0s): /home/hnrk/go-bins/go/bin/go mod tidy
2021/02/18 14:10:09 [INFO] exec (timeout=0s): /home/hnrk/go-bins/go/bin/go build -o /home/hnrk/caddy -ldflags -w -s -trimpath
# github.com/caddyserver/nginx-adapter
/home/hnrk/go/pkg/mod/github.com/caddyserver/[email protected]/nginxadapter.go:66:17: undefined: caddyconfig.JSONIndent
2021/02/18 14:10:10 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-02-18-1410.049791739
2021/02/18 14:10:10 [FATAL] exit status 2

Trouble with latest adapter

I've tried building caddy with 09ce5f0 but I'm not getting the expected adapter behavior.

Output of caddy build-info:

Details
path: github.com/caddyserver/caddy/v2/cmd/caddy
main: github.com/caddyserver/caddy/v2 (devel) 
dependencies:
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
github.com/Masterminds/semver/v3 v3.0.1 h1:2kKm5lb7dKVrt5TYUiAavE6oFc1cFT0057UVGT+JqLk=
github.com/Masterminds/sprig/v3 v3.0.0 h1:KSQz7Nb08/3VU9E4ns29dDxcczhOD1q7O1UfM4G3t3g=
github.com/alecthomas/chroma v0.7.0 h1:z+0HgTUmkpRDRz0SRSdMaqOLfJV4F+N1FPDZUZIDUzw=
github.com/andybalholm/brotli v0.0.0-20190821151343-b60f0d972eeb h1:ZSlUsEd11C/uRzhZHOgANARJ03fkwmjJEa6g2Cqjlo4=
github.com/caddyserver/nginx-adapter v0.0.0-20200209014910-09ce5f0856cf h1:n5c+KNx1KrQ+R+FkKFpBHTBIwcYH2ACwozUzJnCeLzg=
github.com/cenkalti/backoff/v3 v3.1.1 h1:UBHElAnr3ODEbpqPzX8g5sBcASjoLFtt3L/xwJ01L6E=
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/go-acme/lego/v3 v3.3.0 h1:6BePZsOiYA4/w+M7QDytxQtMfCipMPGnWAHs9pWks98=
github.com/golang/groupcache v0.0.0-20191002201903-404acd9df4cc h1:55rEp52jU6bkyslZ1+C/7NGfpQsEc6pxGLAGDOctqbw=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
github.com/ilibs/json5 v1.0.1 h1:3e14wUQM8PyK6Hf1bM+zAQFxfG+N5oZj35x5vCNeQ58=
github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ=
github.com/jsternberg/zap-logfmt v1.2.0 h1:1v+PK4/B48cy8cfQbxL4FmmNZrjnIMr2BsnyEmXqv2o=
github.com/klauspost/compress v1.8.6 h1:970MQcQdxX7hfgc/aqmB4a3grW0ivUVV6i1TLkP8CiE=
github.com/klauspost/cpuid v1.2.2 h1:1xAgYebNnsb9LKCdLOvFWtAxGU/33mjJtyOVbmUa0Us=
github.com/lucas-clemente/quic-go v0.14.1 h1:c1aKoBZKOPA+49q96B1wGkibyPP0AxYh45WuAoq+87E=
github.com/mailgun/timetools v0.0.0-20141028012446-7e6055773c51 h1:Kg/NPZLLC3aAFr1YToMs98dbCdhootQ1hZIvZU28hAQ=
github.com/marten-seemann/chacha20 v0.2.0 h1:f40vqzzx+3GdOmzQoItkLX5WLvHgPgyYqFFIO5Gh4hQ=
github.com/marten-seemann/qpack v0.1.0 h1:/0M7lkda/6mus9B8u34Asqm8ZhHAAt9Ho0vniNuVSVg=
github.com/marten-seemann/qtls v0.4.1 h1:YlT8QP3WCCvvok7MGEZkMldXbyqgr8oFg5/n8Gtbkks=
github.com/mholt/certmagic v0.9.3 h1:RmzuNJ5mpFplDbyS41z+gGgE/py24IX6m0nHZ0yNTQU=
github.com/miekg/dns v1.1.25 h1:dFwPR6SfLtrSwgDcIq2bcU/gVutB4sNApq2HBdqcakg=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/muhammadmuzzammil1998/jsonc v0.0.0-20190906142622-1265e9b150c6 h1:EajWCEv0scxMWyMHWxJbFK70brsPIl4TLQJ0zaOeOiI=
github.com/naoina/go-stringutil v0.1.0 h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks=
github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/vulcand/oxy v1.0.0 h1:7vL5/pjDFzHGbtBEhmlHITUi6KLH4xXTDF33/wrdRKw=
github.com/yuin/goldmark v1.1.17 h1:t7bl7JAmainKs/Uhmr1XZVkRJsgL2UwdTCtTuYL7RAY=
github.com/yuin/goldmark-highlighting v0.0.0-20191202084645-78f32c8dd6d5 h1:QbH7ca1qtgZHrzvcVAEoiJIwBqrXxMOfHYfwZIniIK0=
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
go.uber.org/multierr v1.2.0 h1:6I+W7f5VwC5SV9dNrZ3qXrDB9mD0dyGOi/ZJmYw03T4=
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/square/go-jose.v2 v2.4.1 h1:H0TmLt7/KmzlrDOpa1F+zr0Tk90PbJYBfsVUmRLrf9Y=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=

Then running ./caddy adapt --config ~/Documents/example.conf --adapter nginx --pretty returned:

[WARNING][nginx] nginx.conf:1: map: unrecognized or unsupported nginx directive
[WARNING][nginx] nginx.conf:5: proxy_cache_path: unrecognized or unsupported nginx directive
[WARNING][nginx] nginx.conf:6: server: unrecognized or unsupported nginx directive
[WARNING][nginx] nginx.conf:19: server: unrecognized or unsupported nginx directive
{
        "apps": {
                "http": {}
        }
}

With an nginx.conf of:

Details
map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;
server {
    listen 80;
    listen [::]:80;
    server_name SERVER_NAME_PLACEHOLDER;
    root /home/mastodon/mastodon/public;
# Useful for Let's Encrypt                                                                                                                                                                                                   
    location /.well-known/acme-challenge/ {
        allow all;
    }
    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name SERVER_NAME_PLACEHOLDER;
    ssl_protocols TLSv1.2;
    ssl_ciphers EECDH+AESGCM:EECDH+AES;
    ssl_ecdh_curve prime256v1;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_certificate /etc/letsencrypt/live/SERVER_NAME_PLACEHOLDER/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/SERVER_NAME_PLACEHOLDER/privkey.pem;
    keepalive_timeout 70;
    sendfile on;
    client_max_body_size 80M;
    root /home/mastodon/mastdon/public;
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
    location / {
        try_files $uri @proxy;
    }
    location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
        add_header Cache-Control "public, max-age=31536000, immutable";
        add_header Strict-Transport-Security "max-age=31536000";
        try_files $uri @proxy;
    }
    location /sw.js {
        add_header Cache-Control "public, max-age=0";
        add_header Strict-Transport-Security "max-age=31536000";
        try_files $uri @proxy;
    }
    location @proxy {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Proxy "";
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass_header Server;
        proxy_pass http://localhost:3000;
        proxy_buffering on;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_cache CACHE;
        proxy_cache_valid 200 7d;
        proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
        add_header X-Cached $upstream_cache_status;
        add_header Strict-Transport-Security "max-age=31536000";
        tcp_nodelay on;
    }
    location /api/v1/streaming {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Proxy "";
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass http://localhost:4000;
        proxy_buffering off;
        proxy_redirect off;
        proxy_http_version 1.1;
        tcp_nodelay on;
    }
    error_page 500 501 502 503 504 /500.html;
}

Fails to build

$ ./build_caddy.sh 
++ go list -m github.com/caddyserver/caddy/v2
++ cut -d ' ' -f 2
+ CADDY_VERSION=v2.0.0-beta.20
+ mkdir -p caddy
+ cd caddy
+ curl https://raw.githubusercontent.com/caddyserver/caddy/v2/cmd/caddy/main.go
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    14  100    14    0     0     16      0 --:--:-- --:--:-- --:--:--    16
+ sed -i.bak 's/^)/	_ "github.com\/caddyserver\/nginx-adapter"\
)/' main.go
+ rm main.go.bak
+ go mod init caddy
go: creating new go.mod: module caddy
+ go mod edit -require=github.com/caddyserver/caddy/[email protected]
+ go build -o caddy_v2
can't load package: package caddy: 
main.go:1:1: expected 'package', found 404

I have never used "go" before. This installed on Ubuntu 18.04 using Snap.

Fails to build, NTLM was moved to a separate repo

Someone on the Caddy discord reported this issue:

$ ./xcaddy build v2.0.0-rc.2 --with github.com/caddyserver/nginx-adapter/@bdbb6db7ff9ad6ceb0dcd93f89e396f6365aa5d4 --with github.com/caddyserver/tls.dns@83da3c6805223fd177ac7a2a5c7d103925bdea97 --with github.com/caddyserver/[email protected]
2020/04/12 05:01:24 [INFO] Temporary folder: /tmp/buildenv_2020-04-12-0501.490499347
2020/04/12 05:01:24 [INFO] Writing main module: /tmp/buildenv_2020-04-12-0501.490499347/main.go
2020/04/12 05:01:24 [INFO] Initializing Go module
2020/04/12 05:01:24 [INFO] exec (timeout=10s): /snap/bin/go mod init caddy
go: creating new go.mod: module caddy
2020/04/12 05:01:25 [INFO] Pinning versions
2020/04/12 05:01:25 [INFO] exec (timeout=1m0s): /snap/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
2020/04/12 05:01:26 [INFO] exec (timeout=1m0s): /snap/bin/go get -d -v github.com/caddyserver/nginx-adapter/@bdbb6db7ff9ad6ceb0dcd93f89e396f6365aa5d4
go: github.com/caddyserver/nginx-adapter bdbb6db7ff9ad6ceb0dcd93f89e396f6365aa5d4 => v0.0.0-20200402173715-bdbb6db7ff9a
2020/04/12 05:01:27 [INFO] exec (timeout=1m0s): /snap/bin/go get -d -v github.com/caddyserver/tls.dns@83da3c6805223fd177ac7a2a5c7d103925bdea97
go: github.com/caddyserver/tls.dns 83da3c6805223fd177ac7a2a5c7d103925bdea97 => v0.0.0-20200209203058-83da3c680522
2020/04/12 05:01:28 [INFO] exec (timeout=1m0s): /snap/bin/go get -d -v github.com/caddyserver/[email protected]
go: downloading github.com/caddyserver/ntlm-transport v0.1.0
2020/04/12 05:01:41 [INFO] Build environment ready
2020/04/12 05:01:41 [INFO] Building Caddy
2020/04/12 05:01:41 [INFO] exec (timeout=5m0s): /snap/bin/go build -o /root/go/bin/caddy -ldflags -w -s -trimpath
# github.com/caddyserver/nginx-adapter/
/root/go/pkg/mod/github.com/caddyserver/[email protected]/processors.go:371:11: undefined: reverseproxy.NTLMTransport
# github.com/caddyserver/ntlm-transport
/root/go/pkg/mod/github.com/caddyserver/[email protected]/ntlm.go:161:48: not enough arguments in call to n.HTTPTransport.NewTransport
        have ()
        want (caddy.Context)
2020/04/12 05:01:42 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-04-12-0501.490499347
2020/04/12 05:01:42 [FATAL] exit status 2

Cannot build using xcaddy

System: Ubuntu 22.04 LTS x86_64

Go: 1.18.1

Xcaddy: v0.3.0 h1:3LTHAhHb5YKKqTLLj8kdF9cfGMl4jHV4uRbtw7LBJ6k=

Command: xcaddy build latest --with github.com/caddyserver/nginx-adapter

Errors:
[email protected]/if.go:112:69: cannot use "true" (untyped string constant) as []string value in map literal
[email protected]/if.go:122:75: cannot use roperand (variable of type string) as type []string in map literal

Is the adapter broken ?

Hi there,
I wanted to use your adapter to convert our actual nginx configuration to caddy but it seems it is not working anymore as I'm following your doc , xcaddy, etc....

And I endup using your testing configuration (from git) and this is what the cmd give me :
prproxyfront01t:/tmp/ngin# ./caddy run --config nginx.conf --adapter nginx 2020/11/24 08:47:56.721 INFO using provided configuration {"config_file": "nginx.conf", "config_adapter": "nginx"} [WARNING][nginx] nginx.conf:1: server: unrecognized or unsupported nginx directive 2020/11/24 08:47:56.722 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["127.0.0.1:2019", "localhost:2019", "[::1]:2019"]} 2020/11/24 08:47:56.722 INFO autosaved config {"file": "/root/.config/caddy/autosave.json"} 2020/11/24 08:47:56.722 INFO serving initial configuration 2020/11/24 08:47:56.722 INFO tls cleaned up storage units 2020/11/24 08:47:56.723 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc0002e77a0"}

As you can see, it can't recognize first directive of nginx : server.

This is what I've done to build it :

  • go get -u github.com/caddyserver/xcaddy/cmd/xcaddy
  • go build ~/go/src/github.com/caddyserver/xcaddy/cmd/xcaddy/main.go
  • ~/go/bin/xcaddy build --with github.com/caddyserver/nginx-adapter
  • ./caddy run --config nginx.conf --adapter nginx

Content of nginx.conf
`server {
listen 80;
server_name domain3.com www.domain3.com;
access_log logs/domain3.access.log main;
root html;

location ~ .php$ {
fastcgi_pass 127.0.0.1:1025;
}
}`

Caddy version :
prproxyfront01t:/tmp/ngin# caddy version v2.0.1-0.20200605181936-1dfb11486eac h1:8wT/DuNN9rfMVBglyiPCxaCkVi1ZFVz+NA8pLoaEkFM=

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.