My advice
Don’t waste your time with a complicated configuration that buys you nothing but headaches.
But Mom always says that unsolicited advice is worth what you pay for it.
The answer to your question
See the line in app.yml
that looks like this:
DISCOURSE_HOSTNAME: 'forum.example.com'
and change it to this:
DISCOURSE_HOSTNAME: 'example.com'