Last active
October 26, 2023 11:08
-
-
Save monochromer/5f50a30067489cda8bacafd8b60aca54 to your computer and use it in GitHub Desktop.
Caddy Server and Nginx. Get output of reverse proxy if static file not found
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://localhost:8080 { | |
root * ./public | |
@notStatic { | |
not { | |
file { | |
try_files {path} {path}/ | |
} | |
} | |
} | |
# or short check. | |
#@notStatic not file | |
# serve the app if there's not a static file. | |
reverse_proxy @notStatic http://localhost:9000 | |
# Serve the static file otherwise. | |
file_server | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location / { | |
try_files $uri $uri/ @backend; | |
} | |
location @backend { | |
proxy_pass http://localhost:3000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment