Related to https://mifosforge.jira.com/browse/MIFOSX-2322 This issue was raised by our client and the fix provided did not actually resolve the root issue. As mentioned in the Environment section, our server is a multitenant server and has Nginx set up to proxy requests to Tomcat. Because of this setup though, User defined templates do not work. Looking through the code (https://github.com/openMF/mifosx/blob/develop/fineract-provider/src/main/java/org/apache/fineract/template/service/TemplateMergeService.java) I have found out that the TemplateMergeService uses the HTTP API to return the results for the templates. The issue is it tries to connect to the wrong port and with the wrong tenant. The tomcat server is running on port 8008 and 8443 and the template merge service attempts to connect on port 80/433. Nginx will receive the request and ignore them because of how my routing rules are set up. Our server is setup to give a subdomain to each tenant and nginx uses this subdomain name to set the Fineract-Platform-Id header on the request. Because the API tries to connect on localhost (without any subdomain), the requests made from the API to the API fail to connect. It doesn't really matter in the end, since the service grabs the wrong tenant information. I'm not sure where it gets the tenant identifier from, but it chose "default" as the tenant when it should have used the name of our client instead. (As a precaution, our default tenant is a completely empty tenant)
In summary, the TemplateMergeService attempts to make calls to the API, but fails to ascertain the correct settings to connect to the API. It fails to choose the correct tenant identifier (uses default, when that is not correct), connects on the wrong port (80 instead of 8008), and doesn't use the right server name for the port it connects to. The last two issues are very related as a proper fix would be to either change the port or change the server name. I hope this is enough information to write a fix, but if you need any more information let me know. I'll be glad to help however I can.