I am finding reverse proxy significantly slower compared to apache. Here is how I am testing:
Apache (running on 81 and 444):
<VirtualHost *:444>
ServerAdmin dmd@3e.org
ServerName caddy.3e.org
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
ProxyPass / http://127.0.0.1:9604/ Keepalive=On
ProxyPassReverse / http://127.0.0.1:9604/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLCertificateFile /etc/letsencrypt/live/caddy.3e.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/caddy.3e.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Caddy (running on default 80 and 443):
caddy.3e.org {
reverse_proxy http://127.0.0.1:9604
}
I serve a test page with a simple python script:
admin@caddy:~/mir$ cat serve.py
import http.server
import socketserver
class ThreadedHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
""" handle requests """
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=".", **kwargs)
if __name__ == "__main__":
server_address = ("", 9604)
httpd = ThreadedHTTPServer(server_address, Handler)
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.server_close()
Then, loading the page in Chrome dev tools with “Disable cache” enabled, using the Caddy server I typically get 2x the time to Finish as Apache.
The most obvious difference I see is that Caddy is serving all the images in a single connection:
whereas Apache seems to be using multiple:
I am guessing there is a simple fix for this.
I have the test server up right now, if you want to try. Use the URLs:
caddy: Midjourney v4
apache: https://caddy.3e.org:444/midjourney-v4/
System environment:
$ caddy version
2.6.2
$ uname -a
Linux caddy 6.1.0-18-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux
$ cat /etc/debian_version
12.5
Installed from the debian package, using the package’s standard systemd unit to start.