Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HAProxy: Possible MIME type issue with NextCloud

    Scheduled Pinned Locked Moved Cache/Proxy
    4 Posts 3 Posters 104 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Flemmingss
      last edited by

      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/6

      You 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?

      V 1 Reply Last reply Reply Quote 0
      • V
        viragomann @Flemmingss
        last edited by

        @Flemmingss
        This changes the behavior of the webserver. So why want you do this setting in HAproxy?
        Just configure it on the backend server.

        F 1 Reply Last reply Reply Quote 0
        • F
          Flemmingss @viragomann
          last edited by

          @viragomann I see, a misunderstanding on my part then

          1 Reply Last reply Reply Quote 0
          • J
            Jarester
            last edited by

            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!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.