Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Could you show your full nginx config? –  VBart Nov 26 '12 at 22:09
add comment

2 Answers

up vote 2 down vote accepted

Wow, somehow managed to figure it out. Just wished I figured it out before I put up the bounty...

Essentially you have to have to be very specific with your config due to webmin always wanting to redirect you and nginx having a difficult time trying to rewrite and redirect all of it

To help the next person, make sure you've told webmin its going to be in another directory in /etc/webmin/config

NOTE: Slashes are very important in the rest of this answer. Removing then causes the pain and suffering in the original question

webprefix=/admin/quackwall-webmin
webprefixnoredir=1

Next, you need to configure nginx. This is the hard part, but I've tried to explain what each part does

# Proxy for webmin
# Last slash is important
location /admin/quackwall-webmin/ {
    # Tell nginx that we want to proxy everything here to the local webmin server
    # Last slash is important
    proxy_pass http://127.0.0.1:10000/;
    # Change the response Location: header to come from our proxy directory, not the server
    # Fixes initial redirect after login
    proxy_redirect http://$host:10000/ /admin/quackwall-webmin/;
    # Also fixes initial redirect after login
    proxy_set_header        Host            $host;
}

Restart both nginx and webmin, then they both should work.


Side note, if since your proxying webmin through nginx and webmin happens to reside on the same server nginx is, you can set these options in /etc/webmin/miniserv.conf so its not exposed

bind=127.0.0.1
sockets=
share|improve this answer
add comment
location /admin/quackwall-webmin/ {
    proxy_pass http://127.0.0.1:10000/;
    proxy_set_header Host $host;
}
share|improve this answer
    
I've tried this before, but I tried it again just to show you what happens. Login page, CSS, and images load, however when logging in it just shows the login page again. Last line in miniserv.log shows 127.0.0.1 - - [26/Nov/2012:16:19:18 -0500] "POST //session_login.cgi HTTP/1.0" 401 2460 –  TheLQ Nov 26 '12 at 21:21
    
Somehow figured it out. See my answer –  TheLQ Nov 26 '12 at 23:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.