HAProxy: Possible MIME type issue with NextCloud
-
Hi.
I am not sure if this is a NextCloud issue, or a pfSense/HAproxy issue, but I try here as it might be relevant.
My setup:
- I run pfSense with HAProxy and ACME.
- https://nextcloud.mydomain.com will direct to my internal nextcloud server https://10.0.24.10:3334/
The issue
The problem is that images get downloaded insted of opened in the web picture viewer, anyway, I found this solution for Nginx: https://help.nextcloud.com/t/unable-to-open-pictures-in-nextcloud-it-is-just-just-downloading/219545/6You see, behind Nextcloud is a web server. Either Nginx or Apache. And these web servers serve every file required by the front end. Now, these files include activity-api.mjs, activity-sidebar.mjs and the good old viewer-main.mjs. What I’ve noticed was that every single one of these ends with mjs, an alternative JavaScript file name extension used for modules (hence the m), and that only these files were failing to load. Long story short, I modified the mime.types file (for me it was located in /usr/local/etc/nginx). There was a line similar to: application/javascript js; which I had to rewrite to include mjs files: application/javascript js mjs; So yeah, that’s it. This is the solution to anyone having this problem. I believe it’s the same for people having this problem on Apache.
Is this somthing that may be done with HAProxy?
-
@Flemmingss
This changes the behavior of the webserver. So why want you do this setting in HAproxy?
Just configure it on the backend server. -
@viragomann I see, a misunderstanding on my part then
-
Hi there,
Thanks for the detailed explanation—this is a good catch. Your suspicion is right: this issue isn’t caused by pfSense or HAProxy, but by the web server behind Nextcloud (likely Apache or Nginx) not serving .mjs files with the correct MIME type.
HAProxy simply acts as a reverse proxy and does not handle or modify MIME types. It forwards the request to your backend server (10.0.24.10:3334 in this case), which is responsible for serving static content like .mjs files. To fix it:
- For Nginx, modify mime.types to include:
application/javascript js mjs;
- For Apache, add:
AddType application/javascript .mjs
Once this change is in place, the viewer and other JS modules should load properly through HAProxy.
As a side note, if you're ever doing advanced tasks like proxy rotation for web scraping or external API access, that’s something HAProxy can help with—but it doesn’t apply here.
Let me know if you'd like help locating your web server config!