Proxying webmin with nginx

Posted by TheLQ on Server Fault See other posts from Server Fault or by TheLQ
Published on 2012-10-29T20:29:34Z Indexed on 2012/11/26 23:07 UTC
Read the original article Hit count: 616

Filed under:
|

I am attempting to proxy webmin behind nginx for various reasons that are outside the scope of this question. However I've been trying for a while now and can't seem to figure it out and think I'm to the point where I've exhausted all the permutations of the config file I can think of.

What I have now: relevant nginx config (commented out options removed, I tried many)

    # Proxy for webmin
    location /admin/quackwall-webmin {
        proxy_pass http://127.0.0.1:10000; # Also tried ending with /admin/quackwall-webmin
        proxy_set_header        Host            $host;
    }

/etc/webmin/config - Relevant parts

webprefix=/admin/quackwall-webmin
webprefixnoredir=1
referer=(nginx domain name)

Webmin itself is on the standard ports, listening on all addresses temporarily for debugging. SSL has been disabled for right now.

So I make a standard request for the login page. However all the CSS and images are broken, with the standard login page returned for all of the resources. In the webmin miniserv logs I see

127.0.0.1 - - [29/Oct/2012:12:29:00 -0400] "GET /admin/quackwall-webmin/session_login.cgi HTTP/1.0" 401 2453
127.0.0.1 - - [29/Oct/2012:12:29:01 -0400] "GET /admin/quackwall-webmin/unauthenticated/style.css HTTP/1.0" 401 2453
127.0.0.1 - - [29/Oct/2012:12:29:01 -0400] "GET /admin/quackwall-webmin/unauthenticated/sorttable.js HTTP/1.0" 401 2453
127.0.0.1 - - [29/Oct/2012:12:29:01 -0400] "GET /admin/quackwall-webmin/unauthenticated/toggleview.js HTTP/1.0" 401 2453

So all the URL's are returning 401s. Interestingly ngrep seems to show that the requests suceeded on the backend communication between nginx and webmin

T 127.0.0.1:58908 -> 127.0.0.1:10000 [AP]
  POST /admin/quackwall-webmin/session_login.cgi HTTP/1.0..Host: (host)..Connection: close..User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW
  64; rv:16.0) Gecko/20100101 Firefox/16.0..Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8..Accept-Language: en-US,en;q=0.5.
  .Accept-Encoding: gzip, deflate..Referer: http://(host)/admin/quackwall-webmin/session_login.cgi..Cookie: testing=1..Cache-Control: ma
  x-age=0..Content-Type: application/x-www-form-urlencoded..Content-Length: 41....page=%2F&user=(user)&pass=(pass)

T 127.0.0.1:10000 -> 127.0.0.1:58908 [AP]
  HTTP/1.0 200 Document follows..

Various other permutations of these config options and others show similar results, with the URL sent to webmin by nginx either being /admin/quackwall-webmin/session_login.cgi, /admin/quackwall-webmin//session_login.cgi, and just /session_login.cgi. All give 201 Unauthenticated responses. All requests, even those that somewhat succeed (as in I can actually load the resources of the page)

Is changing the webprefix in webmin even supported? What am I doing wrong? What else can I try?

© Server Fault or respective owner

Related posts about nginx

Related posts about webmin