How to point subdir to VM?

Thankyou

Hi @radenmas,

That configuration you tried appears to be valid.

As long as your VM is listening at http://VMIPADDRESS:80, it will respond to Caddy’s proxy and that response will be carried to the client.

Let us know if you’re encountering any specific issues with that setup.

The weird thing is that it doesn’t work. Gives error 404.

But anyway I got it working by copy paste edit a bunch of codes I found searching around this forum.

Unfortunately now electricity is dead so I can’t share the config :frowning:

Oh, I’ve got a feeling I know what it was! Missed it the first time around.

Your site label is subdomain.example.com/subdir, but you were proxing from the base URL /subdir, which means that accessing your site would have been giving out those 404s unless you browsed to subdomain.example.com/subdir/subdir.

Using proxy / VMIPADDRESS would’ve been the correct way to go - or alternately, using subdomain.example.com (without the /subdir) for your site label.

this is the setting that works

subdomain.example.com {

rewrite {
if {path} not /
if {path} not_starts_with /subdir
to /subdir{uri}
}

proxy /subdir 192.168.31.181:81 {
websocket
without /subdir
transparent
insecure_skip_verify
except /index.html /robots.txt
}
}

the result is kinda weird, but subdomain.example.com/subdir does point to VM while subdomain.example.com to main index on caddy server

1 Like

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