DWC 2.0.0 broke my reverse porxy

  • For a while, I've been running a NGINX based reverse proxy to access my Duet. Since I upgraded to DWC 2.0.0-RC2 (which looks great fyi) my setup seems to have been broken 😞 . Below, I've included the relevant part of my config file. What has changed since the previous DWC/what am I doing wrong?

    server {
            index index.php index.html index.htm;                                   # possible index files
            location = /dwc/ {
                    proxy_set_header Host $host;
                    proxy_http_version 1.1;                                         # http protocol for the destination
                    proxy_set_header Upgrade $http_upgrade;                         # allow upgrading the connection
                    proxy_set_header Connection "connection_upgrade";
                    client_max_body_size 0;                                         # required to allow uploading the gcode files
                    proxy_request_buffering off;                                    # prevents buffers, for best performance

  • Up to now, I have not run it in proxy mode, since there was bound to be issues.

    I have now tried it, and as you say there are issues. The ones I was able to find:

    • hard-coded http links - I have reported this in the other main thread. While you can change this yourself, if you will only be using it in https mode, by hard-coding it to https, the better option would be to create an If statement that looks for (location.protocol != 'https:') and then using http, and otherwise, use https.
    • The new interface have addresses that look like folders, for example Macros are at /Files/Macros on the Duet. I am not sure how well a path is translated using the reverse proxy detail you and I had. I added a new location that look like:
    location ~/(.*)$ {
                    proxy_pass http://{name.local or ip}/$1;
                    proxy_set_header Host $host;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection "upgrade";
                    client_max_body_size 0;
                    proxy_request_buffering off;

    The idea is that we 'catch' everything after the first "/" as variable number 1 ($1) and then append it to the server, after the first "/"

    There may be other issues as well, just have not found them yet.

    To manually change the hard coded http links, you need to extract the gzipped javascript (inside the js folder), to reveal the actual .js file - you can then edit it in your favorite text editor. A sample of code that should result in the correct result (supporting both options, using the ternary operator) is (location.protocol == 'http:' ? "http://":"https://") - the idea is to replace the string "http://" with this everywhere it may be required. Finally remember to gzip it again and upload the new files.


Looks like your connection to Duet3D was lost, please wait while we try to reconnect.