Question

I already have a working https site running. My config below is working fine for webmin. Except that when I login the web address rewrites the port no 10000 next to it, therefore getting error server not found. can anyone help me to correct this please?

server {

 server_name webmin.example.com;
                listen 443;
                ssl on;
                ssl_certificate /etc/webmin/miniserv.pem;
                ssl_certificate_key /etc/webmin/miniserv.pem;
                access_log off;
                error_log off;
                location /RequestDenied {
                return 418;
    }

        location / {
                proxy_pass      https://127.0.0.1:10000;
                proxy_redirect  off;

                #Proxy Settings
                proxy_redirect     off;
                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_max_temp_file_size 0;
                proxy_connect_timeout      90;
                proxy_send_timeout         90;
                proxy_read_timeout         90;
                proxy_buffer_size          128k;
                proxy_buffers              32 32k;
                proxy_busy_buffers_size    256k;
                proxy_temp_file_write_size 256k;
        }
}
Was it helpful?

Solution

Replace the proxy_set_header Host $host; line with proxy_set_header Host $host:$server_port; to redirect the link without port number.

server {
  server_name webmin.example.com;
  listen 443;
  ssl on;
  ssl_certificate /etc/webmin/miniserv.pem;
  ssl_certificate_key /etc/webmin/miniserv.pem;
  access_log off;
  error_log off;

  location /RequestDenied {
    return 418;
  }

  location / {
    proxy_pass      https://127.0.0.1:10000;
    proxy_redirect  off;

    #Proxy Settings
    proxy_redirect     off;
    proxy_set_header   Host             $host:$server_port;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

    proxy_max_temp_file_size 0;
    proxy_connect_timeout      90;
    proxy_send_timeout         90;
    proxy_read_timeout         90;
    proxy_buffer_size          128k;
    proxy_buffers              32 32k;
    proxy_busy_buffers_size    256k;
    proxy_temp_file_write_size 256k;
  }
}

OTHER TIPS

I had a lot of problems setting up webmin proxy_pass to a subfolder with nginx, and it cost me half day to figure out it was just the "/" after the subfolder name CANNOT be omitted.

No complicated settings needed actually... Details at https://github.com/webmin/webmin/issues/420#issuecomment-867456248

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