Come faccio a replicare in nginx ciò che ho fatto in htaccess?

Use nginx outside of docker container (see Running other websites on the same machine as Discourse) and you can rewrite those URLs using nginx configuration.

Syntax is:

server {
  server_name  sub.domain.com;
  rewrite ^(.*) http://12.34.56.78/a/particular/path/ permanent;
}