DWC2 and nginx reverse proxy - cont.



  • I have decided it is time to pick up my reverse proxy endavours where I left them at the end of these threads 1 and 2.

    The end goal is to have mydomain.com/dwc lead to well... dwc. A number of other locations are also defined in the same reverse proxy, doing various things. On the forum I have seen others using a catch all location block (ie. location / { } ) for this purpose. While this config works for me, is leaves out the /dwc part of what I want.

    In the config below I started to experiment with adding locations for all the missing paths, but this cannot the way to go. Anyone more experienced that can explain to me how I can achieve what I want?

    mydomain.conf

    [...]
    location /dwc/ {
    	include /etc/nginx/proxy_params;
    	client_max_body_size 0;										# Don't limit upload size and pass it on immediately without buffering
    	proxy_http_version 1.1;										# WebSockets need explicid http 1.1
    	proxy_set_header Upgrade $http_upgrade;						# Make nginx treat this as a WebSocket
    	proxy_set_header Connection "upgrade";						# Make nginx treat this as a WebSocket
    
    	proxy_pass http://websocket;
        }
    
        location /css/app.0b5b36ba.css {
    	proxy_pass http://websocket;
        }
    
        location /js/app.cc04b2b3.js {
    	proxy_pass http://websocket;
        }
    [...]
    

    nginx.conf:

    [...]
    map $http_upgrade $connection_upgrade {
            	default upgrade;
            	'' close;
        	}
     
        	upstream websocket {
            	server 192.168.1.55;
        	}
    [...]
    

  • administrators

    I don't think it's a nice solution to redirect static DWC2 resources. You may be better of building DWC2 with publicPath set to /dwc instead of / in your case. This will create a new bundle that loads DWC2-related files from /dwc instead of /.



  • @chrishamm said in DWC2 and nginx reverse proxy - cont.:

    I don't think it's a nice solution to redirect static DWC2 resources. You may be better of building DWC2 with publicPath set to /dwc instead of / in your case. This will create a new bundle that loads DWC2-related files from /dwc instead of /.

    I agree it is not a nice solution, or even a solution at all. While rebuilding DWC2 custom for me, will most likely work, and I have though about it as well. I am not a fan of having to build firmware myself each time an update comes around. Unless I can convince you the publicPath should be set to /dwc by default 😉 .


Log in to reply