Howto use nginx config adapter


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.

  1. Entered caddy source directory
  2. Executed “go get
  3. 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.)

Please help!

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.

1 Like

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 :slight_smile:

  1. in terminal, enter : git clone -b v2 “GitHub - caddyserver/caddy: Fast, multi-platform web server with automatic HTTPS
  2. enter to the directory, and : go get
  3. add “_ “”” line to “list of imports” which located as …/modules/standard/import.go
  4. then enter the directory …/cmd/caddy and execute “go build”
  5. 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:

But yeah, that process is the right idea.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.