But since you already have try_files, all you need to do is add / to the end of your existing one for it to fallback to serving the index file!
try_files {path}.html {path} /
Also, I went ahead and edited your post to fix your Caddyfile’s formatting. Please use ``` on the lines before and after your config to use code formatting to preserve whitespace. Much easier to read.
Thank you for your help, but sadly not working.
When I’m looking in status
{"level":"info","ts":1590786381.9126651,"msg":"using provided configuration","config_file":"/etc/caddy/Caddy
May 29 21:06:21 d caddy[6591]: run: adapting config using caddyfile: parsing caddyfile tokens for 'rewrite': /etc/caddy/Caddyfile:77 - Erro
May 29 21:06:21 d systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
May 29 21:06:21 d systemd[1]: caddy.service: Failed with result 'exit-code'.
Here is working code from nginx
server {
listen 80;
server_name xxxxxx.net;
charset utf-8;
root /var/www/xxxxxx.net/html;
index index.html index.htm;
# Always serve index.html for any request
location / {
root /var/www/xxxxxx.net/html;
try_files $uri /index.html;
}
error_log /var/log/nginx/xxxxxx-error.log;
access_log /var/log/nginx/xxxxxx-access.log;
}
Thank you,
I did that, remove old rewrite directive, now my caddyfile looks like this (after caddy fmt) but not work as expected. In my app, when I’m pressing F5 (Refresh) my site show me 404 page, but not refresh current page.
Will be appreciate for the help.
What does your full Caddyfile look like at this point? What do your logs say? How are you reloading Caddy with your config changes? Are you sure you reloaded Caddy’s config?
You can run caddy fmt --overwrite Caddyfile to fix your Caddyfile’s formatting.
FYI that doesn’t necessarily reload the configuration, that just stops the server (downtime! ) and starts it again. Depending on your service file and config that doesn’t change the configuration - always use reload instead.
How can we reproduce the issue that you’re experiencing?