Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    DWC 2.0.0 broke my reverse porxy

    Scheduled Pinned Locked Moved
    Duet Web Control
    3
    6
    884
    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.
    • Nxt-1undefined
      Nxt-1
      last edited by

      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_pass http://192.168.178.147/;
                      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
      
              }
      }
      

      Duet3D and delta printer enthousiast. Buildlog
      Looking for Duet3D configuration support, check out Nxt-3D

      1 Reply Last reply Reply Quote 0
      • Jacotheronundefined
        Jacotheron
        last edited by Jacotheron

        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.

        1 Reply Last reply Reply Quote 0
        • Nxt-1undefined
          Nxt-1
          last edited by

          I realize this tread is quite dusty by now, but did you ever manage to get the Nginx revere proxy to work with DWC2 @Jacotheron? I'v recently gotten to trying again, but I have only gotten the same results as with your config but done differently. The webpage/UI loads, but no the JS's do not get loaded, thus no connection to the Duet is established.

          Duet3D and delta printer enthousiast. Buildlog
          Looking for Duet3D configuration support, check out Nxt-3D

          1 Reply Last reply Reply Quote 0
          • Jacotheronundefined
            Jacotheron
            last edited by

            I haven't looked at this recently, since DWC 2.0 is currently is RC and I have removed my proxy pi for preparation for a local expo I am headed to.

            How I would go about to try again, is to get it like we had it before, and then go through the http logs on the pi as well as the web browser console (you get when you go to Inspect Element etc). Typically they should contain the cause of errors (for example missing javascript file), and then specifically target the issues found.

            Nxt-1undefined 1 Reply Last reply Reply Quote 0
            • Nxt-1undefined
              Nxt-1 @Jacotheron
              last edited by

              @jacotheron There are two issues that I can see, hardcoded http and missing JS.
              0_1561910467467_32247e15-f577-4953-9586-ec52009227a0-image.png 0_1561910408772_c22a2765-c461-48cf-a9d3-32139bfcb263-image.png

              Duet3D and delta printer enthousiast. Buildlog
              Looking for Duet3D configuration support, check out Nxt-3D

              1 Reply Last reply Reply Quote 0
              • wilrikerundefined
                wilriker
                last edited by wilriker

                I have a reverse proxy setup to connect to my Duet from remote and it works flawlessly with DWC 2RC7. I remember there being an issue with reverse proxy in earlier release candidates and I don't remember which one actually fixed it but it works now.

                Though I have to say I only use HTTP (encryption is implemented over an SSH tunnel) and a subdomain in my specific setup:

                server {
                        listen 80;
                        server_name duet.localhost;
                
                        # Some upgrades here to be (able to be) more efficient
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";
                        
                        # Tell upstream where this request is coming from
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header X-Forwarded-Proto $scheme;
                        proxy_set_header X-Forwarded-Host $http_host;
                
                        location / {
                                proxy_pass http://192.168.178.22;
                                proxy_set_header Host $http_host;
                
                                # Don't limit upload size and pass it on immediately without buffering
                                client_max_body_size 0;
                                proxy_request_buffering off;
                        }
                }
                

                EDIT: Regarding HTTPS I just create a Pull Request that replaces the hard-coded http: by location.protocol as mentioned by @Jacotheron.

                Manuel
                Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
                with probably always latest firmware/DWC (incl. betas or self-compiled)
                My Tool Collection

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Unless otherwise noted, all forum content is licensed under CC-BY-SA