Dockerized Wordpress + Discourse + Caddy

I’ve seen the form /index.php?_url={uri} before, but it seems to be a case of some form of citogenesis - I’ve never found in the WordPress documentation that this query parameter should be specified, and don’t believe it has any particular effect. Whenever I use WordPress that isn’t simply the official Docker WordPress image, I just rewrite to {path} {path}/ /index.php?{query}, which works fine.

Caddyfile:

    blog.example.com {
      root /var/www/html
      gzip
      push
      errors stderr
      log stdout
      fastcgi / wp-main:9000 php
    }

You’re right, it looks like the security.limit_extensions errors are gone and replaced by 200s (yay) 404s (boo). This is what I’m seeing currently:

caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:10 +0000] "GET / HTTP/1.1" 404 38
wp-main_1          | 172.xx.xx.xx -  23/Apr/2018:03:52:23 +0000 "GET /wp-admin/install.php" 200
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:23 +0000] "GET /wp-admin/install.php HTTP/1.1" 200 4004
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:24 +0000] "GET /wp-admin/css/install.min.css?ver=4.9.5 HTTP/1.1" 404 38
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:24 +0000] "GET /wp-includes/css/dashicons.min.css?ver=4.9.5 HTTP/1.1" 404 38
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:24 +0000] "GET /wp-includes/css/buttons.min.css?ver=4.9.5 HTTP/1.1" 404 38
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:24 +0000] "GET /wp-includes/js/jquery/jquery.js?ver=1.12.4 HTTP/1.1" 404 38
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:24 +0000] "GET /wp-admin/js/language-chooser.min.js?ver=4.9.5 HTTP/1.1" 404 38
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:03:52:24 +0000] "GET /wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 HTTP/1.1" 404 38

Isn’t the rewrite supposed to go there?

rewrite {
  to {path} {path}/ /index.php?{query}
}
Caddyfile
blog.example.com {
  root /var/www/html
  gzip
  push
  errors stderr
  log stdout
  fastcgi / wp-main:9000 php
  rewrite {
    to {path} {path}/ /index.php?{query}
  }
}

With that bit in there I get a screen full of 302 errors:

wp-main_1          | 172.xx.xx.xx -  23/Apr/2018:05:27:55 +0000 "GET /index.php" 302
caddy_1            | 172.xx.xx.xx - - [23/Apr/2018:05:27:55 +0000] "GET /wp-admin/install.php HTTP/1.1" 302 23

302s aren’t errors, they’re redirections - specifically, non-cache-able redirections.

Since there are zero redirections in your Caddyfile, the only source of a redirection would logically be the PHP script itself, which seems to indicate that the FastCGI is working, at least. Try a curl -IL example.com and look for a Location header in the response.

HTTP/1.1 302 Found
Cache-Control: no-cache, must-revalidate, max-age=0
Content-Type: text/html; charset=UTF-8
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Location: https://blog.example.com/wp-admin/install.php
Server: Caddy
Status: 302 Found
X-Powered-By: PHP/7.2.4

Looks good; seems to be redirecting to first-time setup. Now follow the chain; try curl -IL https://blog.example.com/wp-admin/install.php?

Results from that query are identical. Isn’t it somewhat of a step backwards since the first-time setup page was loading before (though the CSS and JS was 404)?

This gets rid of the 302 for the /wp-admin/install.php, but still throws 302s and 404s for the CSS and JS in /wp-include:

  rewrite {
      if {path} not_match ^\/wp-admin
      to {path} {path}/ /index.php?{query}
  }
caddy_1            | xx.xx.xx.xx - - [23/Apr/2018:06:11:04 +0000] "GET /wp-admin/css/install.min.css?ver=4.9.5 HTTP/2.0" 404 38
wp-main_1          | xx.xx.xx.xx -  23/Apr/2018:06:11:04 +0000 "GET /index.php" 302
caddy_1            | xx.xx.xx.xx - - [23/Apr/2018:06:11:04 +0000] "GET /wp-includes/css/dashicons.min.css?ver=4.9.5 HTTP/2.0" 302 23

Yep, looks like that rewrite is causing some issues. It might be rewriting to index.php when it should be just serving the file off disk?

What do you get from ls -l /var/www/html/wp-includes/css/dashicons.min.css on the Caddy host?

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