Wordpress Caddy


(Matheson Steplock) #1

Hi, I am trying to setup Wordpress on caddy server but it does not seem to be fully working. wp-admin works but the main page does not:

https://www.glennsteplock.ca {
  proxy / 192.168.0.17:333 {
    transparent
    }
  gzip
  tls {
      dns cloudflare
  }
  rewrite {
    if {path} not_match ^\/wp-admin
    to {path} {path}/ /index.php?_url={uri}
    }
  log stdout
}

Any help would be appreciated


(Matthew Fay) #2

Hi @ikifar,

It looks like that guide is for proxying to a WordPress container, not serving WordPress directly.

Did you follow a different guide?

When the main page does not work, can you elaborate on what happens? Do you get an error, or some other unexpected result?


(Matheson Steplock) #3

the home page looks like plain html,
@Whitestrake how would you setup wordpress I am running caddy in docker with an image i created to have the cloudflare plugin

docker build --build-arg \
    plugins=cloudflare,git \
    github.com/abiosoft/caddy-docker.git

(Matthew Fay) #4

Hmm, you don’t have PHP configured in that setup, so any PHP files will just be handled as raw text / HTML. That’s probably breaking your setup.

If you use the WordPress container instead, you don’t need to run and configure PHP in Caddy, you just proxy to it.

As for how I’d set up WordPress, here’s what I use for Docker:

services:
  caddy:
    image: abiosoft/caddy:latest
    command: ["-log", "stdout", "-agree",
      "-email", "letsencrypt@whitestrake.net",
      "-conf", "'/etc/caddyfiles/*.caddy'"]
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./caddyfiles:/etc/caddyfiles
      - ./certificates:/root/.caddy
      - ./sites:/srv
    restart: unless-stopped

  wordpress:
    image: wordpress:php7.0
    depends_on:
      - database
    environment:
      WORDPRESS_DB_PASSWORD: [snip]
      WORDPRESS_DB_HOST: database
    volumes:
      - ./wordpress:/var/www/html
    restart: unless-stopped

  database:
    image: mariadb:latest
    environment:
      MYSQL_ROOT_PASSWORD: [snip]
    volumes:
      - ./database:/var/lib/mysql
    restart: unless-stopped

And this is the part of my Caddyfile that configures my WordPress site:

example.com {
  redir https://www.example.com{uri}
}

www.example.com {
  proxy / wordpress {
    transparent
  }
}

(Matheson Steplock) #5

@Whitestrake How can I setup php for my current setup


(Matthew Fay) #6

Really can’t go past this guide hosted on the Caddyserver repo.

There’s even a great Caddyfile example there.