Migration questions how to migrate "websocket" and "transparent""

1. My Caddy version (caddy version):

RC3

How do i migrate proxy directive with “websocket” and “transparent” inside to reverse_proxy?
Not about matcher but how to replace these two options.

Also how do i replace expires plugin from caddy 1

Hi Andrey,

Refer to our upgrade guide here: Upgrading to Caddy 2 — Caddy Documentation

One other significant difference is that the v2 proxy passes all incoming headers thru by default (including the Host header) and sets the X-Forwarded-For header. In other words, v1’s “transparent” mode is basically the default in v2 (but if you need other headers like X-Real-IP you have to set those yourself). You can still override/customize the Host header using the header_up subdirective.

Websocket proxying “just works” in v2; there is no need to “enable” websockets like in v1.

I’m not familiar with this plugin off-hand, but can look into it this week – or maybe someone else here is more familiar with it and can answer your question. :slight_smile:

Thanks for upgrading to v2!

okay basically i only needed websockets… i will try it.

Functionally, the v1 expires directive allowed for:

  • A method to match what requests you want to specify expiration for
  • Dynamic generation of Expires and Cache-Control headers based on provided duration

Currently, in v2, you can replicate some of the functionality right now, just with matchers and the v2 header directive.

The Expires HTTP header is intended to be a fixed datetime after which the response is considered stale. This header can’t easily be replicated dynamically.

However, Cache-Control can be used to hand off the specified duration to the browser, to allow the client to decide dynamically when the content is stale. This part can be done easily in v2.

For example, to state that all .jpg, .jpeg, and .png files should be cached for one day, you would use something like this:

@images {
  file
  path *.jpg *.jpeg *.png
}
header @images Cache-Control "public, max-age=86400"

The empty file matcher just ensures the requested file exists on disk (no point caching a 404 response).

Request matchers (Caddyfile) — Caddy Documentation
header (Caddyfile directive) — Caddy Documentation

2 Likes

Thank you that is nice

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.