1. My Caddy version (caddy version
):
v2.0.0-beta.20 h1:oUNG1uh0UV8LWLlAVDZolFzk112++V/pxY+fF0HLmlY=
2. How I run Caddy:
More of a conceptual thing at this point but I have the need to be able to serve up static content (error pages, graphics etc) while still also performing a proxy on all other requests to a back-end tomcat server.
For example going to https://my.site.com/static/something.jpg would not get proxied but everything else would.
a. System environment:
Windows Server 2012R2
d. My complete Caddyfile or JSON config:
{
default_sni my.webserver.local
http_port 80
https_port 443
email licensemanager@site.com
}
my.webserver.local {
tls C:\Caddy\Certificate.pem C:\Caddy\Certificate.key
}
my.site.com {
@all_but_static {
not {
path_regexp ^/static
}
}
@root {
path_regexp ^/$
}
@static {
path_regexp ^/static
}
file_server @static {
root C:\Caddy\www
}
header {
Strict-Transport-Security "max-age=31536000;"
Server "C15-83"
X-XSS-Protection "0"
X-Server-Test "19"
}
handle_errors {
@502 {
expression {http.error.status_code} == '502'
}
rewrite @502 https://my.site.com/static/test.html
}
redir @root https://my.site.com/epledge{uri}
tls C:\Caddy\Certificate.pem C:\Caddy\Certificate.key
reverse_proxy @all_but_static http://localhost:8001
log {
output file C:\Caddy\Logs\my_site_com_access.log {
roll_size 100
roll_keep 7
}
}
}
3. The problem Iām having:
Iām wanting to be able to proxy all request to the back-end tomcat server except for when the url contains /static. Iām trying to use the path_regexp matchers and it seems to work except that the static file contents are not being served up (I do get a response of 200 though).
If i modify the config file as such I am able to access the test.html file. However this wont work the way I need it to because our sites are mixed between being root URLās or having a context defined (/something). Ideally everything but /static would need to be ran through the proxy.
{
default_sni my.webserver.local
http_port 80
https_port 443
email licensemanager@site.com
}
my.webserver.local {
tls C:\Caddy\Certificate.pem C:\Caddy\Certificate.key
}
my.site.com {
@all_but_static {
not {
path_regexp ^/static|^/test.html
}
}
@root {
path_regexp ^/$
}
@static {
path_regexp ^/static
}
file_server {
root C:\Caddy\www
}
header {
Strict-Transport-Security "max-age=31536000;"
Server "C15-83"
X-XSS-Protection "0"
X-Server-Test "20"
}
handle_errors {
@502 {
expression {http.error.status_code} == '502'
}
rewrite @502 https://my.site.com/static/test.html
}
redir @root https://my.site.com/epledge{uri}
tls C:\Caddy\Certificate.pem C:\Caddy\Certificate.key
reverse_proxy @all_but_static http://localhost:8001
log {
output file C:\Caddy\Logs\my_site_com_access.log {
roll_size 100
roll_keep 7
}
}
}
4. Error messages and/or full log output:
No errors from access log and running debug in the config and watching the console doesnāt show any errors.
5. What I already tried:
Just about everything I can find on google, but Iām still very new to Caddy so I can be easily skipping or not understanding something.