Redirect static url to internal url which changes

1. The problem I’m having:

Hi,

I`m trying to redirect a static url to a file on a server which may change over time.

For example the static url would like like https://update.vncautomotive.com/windowsapp and i would like to redirect to the internal server link which would be https://update.vncautomotive.com/link/YmmJNn8TagKn

The internal link can change each time we release the new windowsapp.

2. Error messages and/or full log output:


3. Caddy version:

v2.10.0 h1:fonubSaQKF1YANl8TXqGcn4IbIRUDdfAkpcsfI/vX5U=

4. How I installed and ran Caddy:

sudo apt install caddy

a. System environment:

Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble

b. Command:


c. Service/unit/compose file:


d. My complete Caddy config:

{
        auto_https disable_certs
        debug
        log {
                output file /var/log/caddy/access.log
        }
}

https://update.vncautomotive.com:443 {
        tls /var/lib/caddy/vnc/vnc.pem /var/lib/caddy/vnc/vnckey.pem
        reverse_proxy 172.31.43.94
}

5. Links to relevant resources:

Just do redir /windowsapp /link/YmmJNn8TagKn

Reload Caddy anytime you change it.

If you need the link to be dynamic (changed without a Caddy reload), then you’ll need to give more info about how you expect Caddy to be aware of the link. You can write a simple Caddy plugin (in Go) probably.

When you put log in the global options block, you’re not logging “access logs”, you’re logging Caddy’s runtime logs. You need to use the log directive inside the site block to enable access logs. Review the docs.

You can simplify this to just:

update.vncautomotive.com {
3 Likes

Thank you for the reply and the suggestions.

So my Caddy file will look like this

{
auto_https disable_certs
debug
    log {
    output file /var/log/caddy/runtime.log
    }
}

updates.vncautomotive.com {
    tls /var/lib/caddy/vnc/vnc.pem /var/lib/caddy/vnc/vnckey.pem
    reverse_proxy 172.31.44.204
    redir /windowsapp /link/YmmJNn8TagKn
}

Many thanks for your help.

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