Use an SSH tunnel to securely access the web UIs of open-source components without exposing your cluster's internal network structure.
For information about all available methods to access component web UIs, see View the web UIs of open-source components.
Prerequisites
-
You have created a cluster. For more information, see Create a cluster.
-
Ensure that your client machine can connect to the master node of the cluster. For more information, see Bind an EIP.
Access via local port forwarding
This method only lets you view the top-level page. You cannot drill down to view detailed job information.
Local port forwarding maps a port on the master node to a local port on your client machine, allowing you to directly access the web UIs of applications running on the master node.
1. Create an ssh tunnel
On your client machine, open a terminal and use SSH to connect to the cluster's master node. Authenticate with a password or an SSH key pair, depending on your cluster configuration.
Key authentication
ssh -i <path_to_private_key_file> -N -L <local_port>:<master_node_name>:<component_port> root@<master_node_public_ip>
Parameters:
-
-i: Specifies the private key file for authentication. -
-N: Do not execute a remote command. Use this option to only forward ports. -
-L: Specifies local port forwarding. Forwards traffic from the specified local port to the specified remote host and port on the master node. -
<path_to_private_key_file>: The local path to your private key file. For more information, see Manage SSH key pairs. -
<local_port>: An unused port on your client machine. For example, 8156. -
<master_node_name>: The Node Name of the master node, found on the Nodes tab of the cluster details page. For more information, see Obtain the node name. For example, master-1-1. -
<component_port>: The port of the open-source component. For more information, see Default ports of open-source components. For example, the YARN UI port is 8088. -
<master_node_public_ip>: The Public IP Address of the master node, found on the Nodes tab of the cluster details page. For more information, see Obtain the public IP address of a node.
Password authentication
ssh -N -L <local_port>:<master_node_name>:<component_port> root@<master_node_public_ip>
Parameters:
-
-N: Do not execute a remote command. Use this option to only forward ports. -
-L: Specifies local port forwarding. Forwards traffic from the specified local port to the specified remote host and port on the master node. -
<local_port>: An unused port on your client machine. For example, 8156. -
<master_node_name>: The Node Name of the master node, found on the Nodes tab of the cluster details page. For more information, see Obtain the node name. For example, master-1-1. -
<component_port>: The port of the open-source component. For more information, see Default ports of open-source components. For example, the YARN UI port is 8088. -
<master_node_public_ip>: The Public IP Address of the master node, found on the Nodes tab of the cluster details page. For more information, see Obtain the public IP address of a node.
After the tunnel is created, keep the terminal window open. The session remains active and does not return a command prompt.
2. Access the component web UI
In your browser's address bar, enter http://localhost:<local_port> to access the corresponding web UI. Replace <local_port> with the local port that you specified in Step 1. For example, to access the YARN UI, browse to http://localhost:8156.
To access multiple component web UIs simultaneously, repeat this process to create a separate tunnel for each UI on a different local port.
Access via dynamic port forwarding
Dynamic port forwarding creates an SSH tunnel with a SOCKS proxy, allowing local applications such as a web browser to access the web UIs of open-source components on the master node.
1. Create an ssh tunnel
On your client machine, open a terminal and use SSH to connect to the cluster's master node. Authenticate with a password or an SSH key pair, depending on your cluster configuration.
Key authentication
ssh -i <path_to_private_key_file> -N -D <local_port> root@<master_node_public_ip>
Parameters:
-
-i: Specifies the private key file for authentication. -
-N: Do not execute a remote command. Use this option to only forward ports. -
-D: Specifies dynamic port forwarding. Starts a SOCKS proxy server on the specified local port. -
<path_to_private_key_file>: The local path to your private key file. For more information, see Manage SSH key pairs. -
<local_port>: An unused port on your client machine. For example, 8157. -
<master_node_public_ip>: The Public IP Address of the master node, found on the Nodes tab of the cluster details page. For more information, see Obtain the public IP address of a node.
Password authentication
ssh -N -D <local_port> root@<master_node_public_ip>
Parameters:
-
-N: Do not execute a remote command. Use this option to only forward ports. -
-D: Specifies dynamic port forwarding. Starts a SOCKS proxy server on the specified local port. -
<local_port>: An unused port on your client machine. For example, 8157. -
<master_node_public_ip>: The Public IP Address of the master node, found on the Nodes tab of the cluster details page. For more information, see Obtain the public IP address of a node.
After the tunnel is created, keep the terminal window open. The session remains active and does not return a command prompt.
2. Configure browser proxy
After you enable dynamic port forwarding, choose one of the following methods to configure your browser to use the proxy.
Command line (Chrome)
-
Open a terminal and navigate to the installation directory of Google Chrome on your client machine.
Operating system
Default installation directory
macOS X
/Applications/Google\ Chrome.app/Contents/macOS
Linux
/usr/bin/google-chrome
Windows
The default paths for 64-bit and 32-bit systems are:
-
C:\Program Files\Google\Chrome\Application\
-
C:\Program Files (x86)\Google\Chrome\Application\
NoteThe default installation directory for Chrome varies by operating system.
-
-
Configure Google Chrome to use the local SOCKS proxy and launch the browser. Ensure the port matches the one that you specified in Step 1.
NoteThe following examples use port 8157.
macOS X
./Google\ Chrome --proxy-server="socks5://localhost:8157" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" --user-data-dir=/tmp/Linux
chrome --proxy-server="socks5://localhost:8157" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" --user-data-dir=/tmp/Windows
chrome --proxy-server="socks5://localhost:8157" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" --user-data-dir=c:\\tmppath\\
Chrome extension
A browser extension lets you manage and switch proxy settings without affecting regular browsing.
-
Install the SwitchyOmega extension for Chrome.
-
Open the extension's configuration page. Click New profile, enter a Profile name (for example, SSH tunnel), and select PAC Profile for the profile type.
-
In the PAC Script editor, enter the following code.
NoteThis example uses port 8157.
function regExpMatch(url, pattern) { try { return new RegExp(pattern).test(url); } catch (ex) { return false; } } function FindProxyForURL(url, host) { if (shExpMatch(url, "*localhost*")) return "SOCKS5 localhost:8157"; if (shExpMatch(url, "*emr-header*")) return "SOCKS5 localhost:8157"; if (shExpMatch(url, "*emr-worker*")) return "SOCKS5 localhost:8157"; if (shExpMatch(url, "*master*")) return "SOCKS5 localhost:8157"; if (shExpMatch(url, "*core*")) return "SOCKS5 localhost:8157"; return 'DIRECT'; } -
In the left navigation pane, click Apply changes.
-
In the upper-right corner of your browser, click the SwitchyOmega icon and select the SSH tunnel profile you just created.
3. Access the component web UI
In your browser's address bar, enter http://<master_node_name>:<port> to access the corresponding web UI. For example, to access the YARN UI, browse to http://master-1-1:8088.
Parameters:
-
<master_node_name>: The Node Name of the master node, found on the Nodes tab of the cluster details page. For more information, see Obtain the node name. For example, master-1-1. -
<port>: The port for the target component. For a list of component ports, see Default ports of open-source components. For example, the YARN UI port is 8088.
To access the web UIs of multiple open-source components, you only need to change the port number in the URL.
References
-
To access web UIs from the console, see Access open-source component UIs from the console.
-
For answers to frequently asked questions, see FAQ.