1. Caddy version (caddy version
):
2.3.0 Docker caddy:alpine
2. How I run Caddy:
Via docker-compose
a. System environment:
Ubuntu 20.04, latest Docker and Docker Compose, static IPv4
b. Command:
docker-compose up -d
c. Service/unit/compose file:
version: "3"
services:
caddy:
image: caddy:alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddy/Caddyfile/Caddyfile:/etc/caddy/Caddyfile
- ./Caddy/Data:/data
- ./Caddy/Config:/config
db:
image: mysql
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: Database
MYSQL_USER: User
MYSQL_PASSWORD: Password
MYSQL_ROOT_PASSWORD: Password
command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci --init-connect='SET NAMES UTF8;' --innodb-flush-log-at-trx-commit=0
tomcat:
image: tomcat:8.5-jdk11
volumes:
- ./webapp:/usr/local/tomcat/webapps
- ./workdir:/usr/local/tomcat/workdir
environment:
JAVA_OPTS: "-Dportal_working_dir=/usr/local/tomcat/workdir -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xms2048m -Xmx2048m -Djava.security.egd=file:/dev/./urandom"
depends_on:
- db
d. My complete Caddyfile or JSON config:
{
email admin@mydomain.com
}
tomcat.mydomain.com {
reverse_proxy tomcat:8080
}
3. The problem Iâm having:
Normally, we deploy a .war in Tomcat and use Apache2 as reverse proxy. I tried to use Caddy instead. If i go to the site with publicip:8080/myapplication
, everything is loading fine. If i define http://tomcat.mydomain.com
in the Caddy file i can use http://tomcat.mydomain.com/myapplication
without any problems aswell. If i use https://tomcat.mydomain.com
or just tomcat.mydomain.com
, the site is loading, but not complete. Usually we should see a login form. When using https itâs not showing up, but instead itâs showing a loading symbol.
4. Error messages and/or full log output:
A look into the Browsers developer tools say 'Failed to load resource: the server responded with a status of 400 () â https://tomcat.mydomain.com/myapplication/login?16-1.IBehaviorListener.0-tabs-panel&_=1613318058434'
Here is the request:
:method: GET
:scheme: https
:authority: tomcat.mydomain.com
:path: /myapplication/login?18-1.IBehaviorListener.0-tabs-panel&_=1613318314097
Accept: application/xml, text/xml, */*; q=0.01
Cookie: JSESSIONID=A2D6C38EA859607984D92DB16D6D8FB4; adminer_sid=a1b3d168a271ab11179727eaa484b63e; adminer_key=1f8d555e6a1ca0afb1c19b042fbff9a3; adminer_permanent=; adminer_version=4.8.0; _ga=GA1.2.1330864484.1612980505
Accept-Language: de-de
Host: tomcat.mydomain.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15
Referer: https://tomcat.mydomain.com/myapplication/login?18
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Wicket-Ajax-BaseURL: login?18
Wicket-Ajax: true
And the answer:
:status: 400
Date: Sun, 14 Feb 2021 15:58:34 GMT
Content-Length: 821
Content-Language: en
Content-Type: text/html;charset=utf-8
Server: Caddy
5. What I already tried:
The apache configuration is like this:
<IfModule mod_ssl.c>
<VirtualHost 192.168.0.100:443>
ServerName tomcat.myapplication.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass /myapplication ajp://localhost:8090/myapplication
ProxyPassReverse /myapplication ajp://localhost:8090/myapplication
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert.key
</VirtualHost>
</IfModule>
So itâs using the ajp connector of tomcat but that shouldnât be a problem i guess, i go with port 8080. And since http is working with Caddy i expect something to be wrong with https (the certificate is working by the way). But my knowing about webservers is a bit limited. So i tried different things like root * /var/www/html or using tomcat.mydomain.com/myapplication
and reverse_proxy tomcat/myapplication:8080. But nothing worked.
I hope somebody can give me a hint, i guess itâs possible to use Caddy but some sort of setting is missing, maybe something with the headers, but i donât know which one. Or the encoding, i tried to use gzip aswell but nothing changed so far.
Thank you!
Edit: Iâm even too dump to use the ```right