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


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
  ProxyPass / http://localhost:9602/
  ProxyPassReverse / http://localhost:9602/
RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]


I use the ssl protocol with certbot

could you help me ? thanking you

Source: Docker Questions