I’m trying to configure a hostname for my localhost, instead to use http://localhost:8080I want to access like http://mytestcaddy.env, but I don’t know how to write my Caddyfile. I’m using docker to up php and caddy server. If I execute the script, I can access my index.php page.
My Caddyfile
0.0.0.0
root /srv/app
gzip
fastcgi / 127.0.0.1:9000 php
rewrite {
regexp .*
ext /
to /index.php?{query}
}
header / -Server
log stdout
errors stdout
on startup php-fpm --nodaemonize
I tried to change my Caddyfile to use proxy, but i don’t know how works.
I tried like this,
http://mytestcaddy.env
proxy / localhost:8080
root /srv/app
gzip
fastcgi / 127.0.0.1:9000 php
rewrite {
regexp .*
ext /
to /index.php?{query}
}
header / -Server
log stdout
errors stdout
on startup php-fpm --nodaemonize
OR
http://mytestcaddy.env {
proxy / localhost:8080
root /srv/app
gzip
fastcgi / 127.0.0.1:9000 php
rewrite {
regexp .*
ext /
to /index.php?{query}
}
header / -Server
log stdout
errors stdout
on startup php-fpm --nodaemonize
}
My docker-compose.yml
version: "3"
services:
app:
image: caddy-app
container_name: caddy-app
build:
context: .
dockerfile: .docker/Dockerfile
ports:
- 8080:2015
volumes:
- .:/srv/app
My Dockerfile
FROM php:7.2-fpm
LABEL maintainer="rIckSanchez|AndreFigueredo"
LABEL project="Caddy"
COPY . /srv/app
RUN curl --silent --show-error --fail --location \
--header "Accept: application/tar+gzip, application/x-gzip,application/octet-stream" -o - \
"https://caddyserver.com/download/linux/amd64?
plugins=http.expires,http.realip&license=personal" \
| tar --no-same-owner -C /usr/bin/ -xz caddy \
&& chmod 0755 /usr/bin/caddy \
&& /usr/bin/caddy -version
COPY .docker/Caddyfile /etc/Caddyfile
RUN chown -R www-data:www-data /srv/app
CMD ["/usr/bin/caddy", "--conf", "/etc/Caddyfile", "--log","stdout"]
EXPOSE 2015