Sooo I’m trying to
Serve both root directory and images/other files that are in /app/static/
like /app/static/img.png and literally can’t find any way to do it, tried many things with rewrite, tried looking up google, no luck.
domain.com {
root ./app
}
anyone has any idea? I’d be grateful, spent too much time on this already…
well I’d prefer to have no subdomain.
i want domain.com to return normal website and like domain.com/screenshot.png return the file I’ll upload ;s
It would be easier to setup on subdomain for sure but im trying to find a solution to do without it
Well that would be really weird since there are thousands of them, im trying to make a file hosting so i want it all sorted. It was possible in other webservers but i moved to caddy since i want to host multiple domains and its easiest here
Well, they don’t really have a config like caddy.
Ive been using echo before and simply made a few functions in golang
e.File("/", “index.html”)
e.GET("/:id", showImage)
e.POST("/upload", Upload)
Probably i could make proxy and stuff but whats the point to use caddy then. Im pretty sure its possible to do with caddy rewrite, i just don’t know how
because its a bad practice. I don’t want to put everything in one directory with files that are being uploaded. It’s better to not do it at all than do it that way.
That’s pretty weird… not the result I expected - when I sit down next in front of one of my computers with a bash terminal I’ll fiddle around and try and get some results.
The “ext !/” prevents it rewriting directories, and so lets it find index.html in the root.
EDIT:
I then considered the possibility of subdirectories in /static, and came up with:
rewrite {
if {path} not /
to /static{path}/ /static{path} {path}/ {path}
}
Note that even with all those options in the “to” directive, the “if {path} not /” remained necessary. But this now finds index files in subdirectories of static (without “static” being specified), as well as the one in the root.
Is there something wrong with the handling of the path “/” in rewrite?
Great! Seems like it does what I wanted, though prevents from viewing source of the page by redirecting to domain.com/static so its not perfect but yeah root directory works, static works, does its job.
I also came up with idea of just serving both index.html and correct file from static by using proxy and some other framework.