Redir doesn't work anymore

Hello,

GLOBAL REDIRECT TO HTTPS
Note: I have tried to change 308 to 307, 302 and 301 too

:80 {
	redir 308 {
		if {>X-Forwarded-Proto} is http
		/  https://{host}{uri}
	}
}

DOMAIN

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

https://domain.com {
	root /var/www/domain.com/web
	tls itsme@gmail.com
	timeouts 1h
	gzip {
		level 6
		min_length 1400
	}
	fastcgi / /var/run/php/php7.1-fpm.sock php {
		ext     .php
		split   .php
		index   index.php
	}

	cors / {
		origin            https://anotherdomain.com
		methods           POST,GET,OPTIONS,PUT,DELETE
		allow_credentials false
		max_age           1800
	}

	header / {
		Cache-Control "max-age=86400"
		X-Content-Type-Options "nosniff"
		Access-Control-Allow-Origin *
	}

	rewrite {
		if {path} not_match ^\/wp-admin
		to {path} {path}/ /index.php?{query}
	}
}

On DO works fine, not on AWS. Same Ubuntu version of => XENIAL

ERROR

Sep 03 15:53:06 machine caddy[5038]: 2017/09/03 15:53:06 error on 'service' hook: /etc/caddy/Caddyfile:4 - Parse error: Unknown directive '
Sep 03 15:53:06 machine caddy[5038]: 2017/09/03 15:53:06 /etc/caddy/Caddyfile:4 - Parse error: Unknown directive 'redir'

MY CUSTOM CADDY

Server types:
  http
  dns
  net

Caddyfile loaders:
  short
  flag
  default

Event hook plugins:
  hook.service

Other plugins:
  dns.auto
  dns.bind
  dns.cache
  dns.chaos
  dns.debug
  dns.dnssec
  dns.dnstap
  dns.erratic
  dns.errors
  dns.etcd
  dns.file
  dns.health
  dns.hosts
  dns.kubernetes
  dns.loadbalance
  dns.log
  dns.pprof
  dns.prometheus
  dns.proxy
  dns.reverse
  dns.rewrite
  dns.root
  dns.secondary
  dns.tls
  dns.trace
  dns.whoami
  http.basicauth
  http.bind
  http.browse
  http.cache
  http.cgi
  http.cors
  http.errors
  http.expires
  http.expvar
  http.ext
  http.fastcgi
  http.filemanager
  http.grpc
  http.gzip
  http.header
  http.hugo
  http.index
  http.internal
  http.jwt
  http.limits
  http.log
  http.login
  http.markdown
  http.mime
  http.minify
  http.nobots
  http.pprof
  http.prometheus
  http.proxy
  http.push
  http.realip
  http.redir
  http.request_id
  http.rewrite
  http.root
  http.status
  http.templates
  http.timeouts
  http.upload
  http.websocket
  net.host
  shutdown
  startup
  tls
  tls.dns.cloudflare
  tls.dns.digitalocean
  tls.dns.route53
  tls.storage.file

On new machine (AWS) I’ve been used 0.10.7 and 0.10.6 on old machine.
I’ve been tried to change the 0.10.7 to 0.10.6 from old machine, no success also.
What I’m doin wrong?

Thank you.

Hi, this is strange, in your error logs:

Sep 03 15:53:06 machine caddy[5038]: 2017/09/03 15:53:06 error on 'service' hook: /etc/caddy/Caddyfile:4 - Parse error: Unknown directive '
Sep 03 15:53:06 machine caddy[5038]: 2017/09/03 15:53:06 /etc/caddy/Caddyfile:4 - Parse error: Unknown directive 'redir'

It looks like the first line is truncated. What is the full output of that line?

The second line is more sensible, except there isn’t a redir directive on line 4 in either of the Caddyfiles you’ve given. What are the full, complete, unmodified Caddyfiles? (Unless you actually do have a Caddyfile for domain.com, these are clearly modified, so it’s hard to help you from this.) (Either that, or it’s a bug in the parser, but I’m highly suspicious that something else is going on since it works for you on one machine but not another.)

@matt

Editing file caddy.service and after remove -quic and --type=net from execute command, works like a charm. I do not know why. Suggestions?

Oh, yeah, you can’t use HTTP directives like redir with the net server type. :slight_smile: The net server type serves TCP/UDP, not HTTP.