Is it possible to dynamically update reverse proxy configurations?

Suppose that I have a File Browser web application which is accessible at 127.0.0.1:8080 and requests from example.com are forwarded to it via reverse proxy with the following caddy file:

http://example.com {
    reverse_proxy 127.0.0.1:8080
}

now let’s suppose that I updated the File Browser application and new version is available at 127.0.0.1:8081 while the previous version still running at port 8080.

Is it possible that I configure caddy in such a way that, those who are currently using the previous version of File Browser continue to work fine but anyone NEW, who accesses example.com be served with the new version of application (accessible at port 8081)?

What I need is some kind of transparent update mechanism such that current users don’t lose their session but new users are fed the new version (later on that I made sure everyone is on the new version, I will remove the old one)

I don’t think there’s any way for Caddy to know who is an “old user” and who is a “new user”.

I’m not sure I understand what your goal is here. Can’t you just transfer your user accounts from one instance to the other? Why does it matter if they get logged out? Can’t they just log back in?

1 Like

You’d need a way to keep track of which users are on the old one and which are on the new one, this is usually done with cookies. Then you can use the header or header_regexp matcher to proxy them to the right backend.

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