Question

i setting up webmin over nginx (proxy), and a have two problem 1) if i not using rewrite, then webmin redirect me to 10000 port after login 2) if i using mod rewrite, then i see error 310 (net::ERR_TOO_MANY_REDIRECTS): on my browser.

my nginx config:

server {
listen 80;
server_name cp.domain.com www.cp.domain.com;

if ($http_host != "cp.domain.com:10000") {
               rewrite ^ http://cp.domain.com$request_uri permanent;
   }
location / {
proxy_pass http://localhost:10000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
tcp_nodelay on;
}
}

What's problem? Best regards, and thank you

Was it helpful?

Solution

Your nginx reverse proxy setup shouldn't redirect to 10000 unless you have a special proxy_redirect directive that tells nginx to do so otherwise. Something else is doing that.

Because your server block only listens on port 80. So your condition

  $http_host != "cp.domain.com:10000"

will always be true because the port part of $http_host is always 80. That's how the redirect loop occurs. Basically that if block is useless here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top