I saw a project GitHub - caddyserver/nginx-adapter: Run Caddy with your NGINX config and tried to build it.
So I installed go 1.13 and downloaded caddy source from Release 2.0 beta 13 · caddyserver/caddy · GitHub
And now, I want to follow instructions written nginx-adapter project.
- Entered caddy source directory
- Executed “go get github.com/caddyserver/nginx-adapter”
- But how can I add below line
into “list of imports”? I don’t get it at all.
4. And how can I get a build result? (when I execute “go build”, it is done in a second without returning a message, and I don’t know the destination folder.)
Hi there! Actually, the nginx-adapter is still work-in-progress. If you glance at the code in the repo, you’ll see it doesn’t handle
rewrites yet, which I assume you’ll need based on your other thread. I’d say let’s focus on solving the issue you’re facing there.
Ha, I got it.
But, the main reason I am asking for is based on my curiosity.
Is there’s a working solution?
The nginx adapter isn’t a command, so
go build will only compile it to check for errors, not create an executable file. It’s a Caddy plugin, so you add that import as described here: Extending Caddy — Caddy Documentation (near the beginning). Literally just add it to the list of imports. Making your own
main is recommended.
Then compile your own
main (or a modified Caddy main, if you added the import into Caddy’s main package instead of your own) and you will get a binary with that plugin.
So I figured out
- in terminal, enter : git clone -b v2 “GitHub - caddyserver/caddy: Fast, multi-platform web server with automatic HTTPS”
- enter to the directory, and : go get github.com/caddyserver/nginx-adapter
- add “_ “github.com/caddyserver/nginx-adapter”” line to “list of imports” which located as …/modules/standard/import.go
- then enter the directory …/cmd/caddy and execute “go build”
- then I get a working caddy executable with nginx config adapter module is plugged in
Finally I understood how it works. thanks.
Great! Glad you figured it out.
No need to do it in that file, in fact you can do it without modifying Caddy’s source code. Instructions here: https://github.com/caddyserver/caddy/tree/v2#building-with-plugins
But yeah, that process is the right idea.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.