6

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;
        }
}
Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
Tapash
  • 357
  • 1
  • 3
  • 15
  • 11
    I have found my solution after all... sharing my answer just incase if anyone run into same kind of problem replace proxy_set_header Host $host; line to proxy_set_header Host $host:$server_port; #this redirects the link without port no. – Tapash Mar 24 '14 at 12:42
  • Saved me a lot of efforts. Thanks man – Baljeet Bhinder May 27 '19 at 04:52
  • Tapash, please post a full answer with the solution. It's very useful and deserves to be upvoted properly – brasofilo May 01 '20 at 08:42

2 Answers2

10

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;
  }
}
Holger Just
  • 52,918
  • 14
  • 115
  • 123
Tapash
  • 357
  • 1
  • 3
  • 15
1

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

wxrl
  • 11
  • 1