Cannot download js files from server when using reverse proxy

Summary

Unable to download js files like 30.07def5393a51e553bf3a.js from client browser when MM server is deployed behind reverse proxy.

Steps to reproduce

Setup reverse proxy so that http://proxy/path/to/mattermost is translated as http://mmServer

Expected behavior

Browsers can download js files and display top page.

Observed behavior

I have a MM server behind reverse proxy.
I can get root.html and compressed main.8cbef6ef69cc01c40703.js just fine.
But when requiring other js chunks like 30.07def5393a51e553bf3a.js from main file, it fails,
because the file path is wrong and proxy server doesn’t have a route for it.
ie)

Request URL for main.js
http://proxy/path/to/mattermost/static/main.8cbef6ef69cc01c40703.js
-> succeeds
Request URL for other js files required from main.js
http://proxy/static/30.07def5393a51e553bf3a.js
-> fails to resolve because `path/to/mattermost/` is missing

Setting Site URL to http://proxy/path/to/mattermost/ didn’t work.
(As it did not affect request URL for chunks)

How can I fix this? Is there any settings so that I can change request path dynamically?
Or is this caused by proxy server settings?