How to properly configure Apache for a spring boot project that is in a docker

  apache2, docker, spring-boot

I have a spring boot project which is on my production server, in a docker.

I have apache installed on the server (not in a docker).

I notice, with gtmetrix, when I analyze my site, if I query the site with the domain name, gtmetrix tells me that it takes more time than if I directly put the docker ip and port.

for example

through the domain:
TTFB: 2.0s
Redirect: 0ms
Connect: 626ms
Backend: 1.3s

vs

by directly entering the ip and port of docker:
TTFB: 1.3s
Redirect: 0ms
Connect: 152ms
Backend: 1.2s

I don’t think this is normal. I was advised to use Caddy but I think I must have a configuration problem

<VirtualHost *:80>
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName www.my-domaine.fr
  ServerAlias my-domaine.fr
  ProxyPass / http://localhost:9602/
  ProxyPassReverse / http://localhost:9602/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.my-domaine.fr [OR]
RewriteCond %{SERVER_NAME} =my-domaine.fr
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

I use the ssl protocol with certbot

could you help me ? thanking you

Source: Docker Questions

LEAVE A COMMENT