Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Nginx reverse proxy for webmin

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;
        }
}
like image 615
Tapash Avatar asked Mar 24 '14 12:03

Tapash


1 Answers

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;
  }
}
like image 73
Tapash Avatar answered Sep 22 '22 07:09

Tapash