Anchor links fail on default Shiny server

When I upload Rmd files to my cloud shiny server, hash/anchors like [click me](#tag) does nothing. They work fine when I run it locally in the Rstudio viewer and in all browsers. The link also work as expected on shinyapps.io. I installed Shiny Server 1.5.9.923 on Ubuntu 18.04 and all settings are default except that I changed site_dir and log_dir in /etc/shiny-server/shiny-server.conf.

What could be the source of this problem and how can I fix it?

To reproduce the problem, consider this minimal Rmd file:

```
---
output: 
  html_document
runtime: shiny
---

[Click this link to go to second heading](#second)

# First {#first}
<div style="height: 3000px;">spaace</div>

# Second {#second}
Arrived!
```

See this Rmd on my cloud server where the link does not work

See this Rmd on shinyapps.io where the link works