Unblocking a site even with reverse SSH tunnel through a proxy

Abstract: Configure web scraping tools to bypass network restrictions by routing Socks5 traffic through a reverse SSH tunnel exposed on a remote server.

Created: 2026-08-20 by
You can unblock a site by configuring your web scraping tool to route traffic through a Socks5 proxy running on a home device, which is made accessible remotely via a reverse SSH tunnel. This setup requires generating a specific JSON configuration that points to the local endpoint of the tunnel, effectively bypassing network restrictions while maintaining security and connectivity across different operating systems.

Understanding the Network Architecture

The core challenge involves accessing a resource that is blocked or restricted, while simultaneously dealing with network constraints such as firewalls or proxies. The solution leverages a reverse SSH tunnel to expose a local service to the public internet securely. In this architecture, a device within your home network runs a Socks5 proxy server. Because this device is behind a NAT (Network Address Translation) router, it cannot be reached directly from the outside world. By establishing a reverse SSH tunnel from the home device to a remote VPS or server you control, you create a secure channel. Traffic sent to a specific port on the remote server is forwarded through the SSH connection to the Socks5 proxy on the home device. This allows your client application, whether running on Linux, Windows, or macOS, to connect to the remote server's exposed port and have that traffic routed through the home network's proxy. This method is particularly useful for web scraping tasks where IP rotation or specific geographic locations are required, or when standard HTTP proxies are insufficient due to encryption requirements.

Setting Up the Reverse SSH Tunnel

Before configuring the software, you must ensure the tunnel is active. On your home device, execute an SSH command that forwards a remote port to the local Socks5 port. For example, if your Socks5 proxy is listening on port 1080 locally, and you want to expose it on port 2222 of your remote server, the command would look like this:
ssh -R 2222:localhost:1080 [email protected]
This command establishes an encrypted connection to remote-server.com. Any connection made to localhost:2222 on the remote server is automatically tunneled back to localhost:1080 on your home machine. Ensure that the SSH daemon on the remote server permits remote port forwarding by checking the GatewayPorts setting in /etc/ssh/sshd_config. If it is set to no, connections will only be bound to localhost on the server side, which might prevent external clients from reaching the tunnel depending on your firewall rules. Setting it to yes or clientspecified allows broader access, but always consider the security implications of exposing internal services.

Generating the JSON Configuration

Most modern web scraping frameworks and tools accept a JSON configuration file to define proxy settings. You need to construct a JSON object that specifies the type of proxy, the host, and the port. Since the traffic is being routed through the SSH tunnel, the "host" should point to the remote server where the tunnel is exposed, and the "port" should be the remote port you mapped earlier. Here is an example of the required JSON structure for a Socks5 proxy:
{
  "proxy": {
    "type": "socks5",
    "host": "remote-server.com",
    "port": 2222,
    "username": null,
    "password": null
  }
}
If your Socks5 proxy on the home network requires authentication, you must include the username and password fields in the JSON. However, since the SSH tunnel itself provides encryption and integrity, many users prefer to keep the Socks5 proxy anonymous or use strong credentials at the application level. It is crucial that the type field matches the protocol your scraping tool expects. Using http here instead of socks5 will likely result in connection failures because the underlying transport is SOCKS, not HTTP.

Integrating with Your Scraping Tool

Once the JSON file is saved, typically as config.json, you need to instruct your web scraping library to load this configuration. For instance, if you are using Python with a library like requests or scrapy, you would parse the JSON and pass the proxy details to the session or request handler. For a generic implementation, you might read the file and update the environment variables or session parameters:
import json
import requests

with open('config.json', 'r') as f:
    config = json.load(f)

proxy_url = f"{config['proxy']['type']}://{config['proxy']['host']}:{config['proxy']['port']}"
if config['proxy'].get('username'):
    auth = f"{config['proxy']['username']}:{config['proxy']['password']}"
    proxy_url = f"{config['proxy']['type']}://{auth}@{config['proxy']['host']}:{config['proxy']['port']}"

response = requests.get('https://example.com', proxies={'http': proxy_url, 'https': proxy_url})
print(response.text)
This approach ensures that all outbound HTTP and HTTPS requests are routed through the SSH tunnel. If you encounter issues, verify that the remote server's firewall allows inbound traffic on the specified port. Additionally, check the logs on your home device to ensure the Socks5 proxy is accepting connections. This method works seamlessly across Linux, Windows, and MacOS, provided the SSH client and Socks5 server are installed and configured correctly on the respective home devices. For more complex networking scenarios, such as handling multiple tunnels or dynamic IP changes, you may need to adjust your routing tables or use dedicated tunnel management tools.

Troubleshooting Common Issues

If the connection fails, first check if the SSH tunnel is alive. Use netstat or ss on the remote server to see if port 2222 is listening. If it is not, the reverse tunnel has dropped, possibly due to network instability. Implementing a keep-alive mechanism or using a service manager like systemd or tmux can help maintain the connection. Another common issue is DNS resolution. Ensure that the hostname remote-server.com resolves correctly from the machine running the scraper. If you are using an IP address directly, skip DNS checks. Also, verify that the Socks5 proxy on the home network is not blocking the source IP of the SSH connection, although this is rare in typical home setups. Finally, test the tunnel independently using a simple tool like curl before integrating it into your full scraping pipeline to isolate configuration errors.

Frequently Asked Questions

Can I use this method for HTTP proxies instead of Socks5?

Yes, but you must change the proxy type in the JSON configuration to http and ensure your home device is running an HTTP proxy server instead of Socks5. The SSH tunneling mechanism remains identical, but the protocol negotiation differs slightly at the application layer.

Is it safe to expose the SSH tunnel port to the public internet?

It is relatively safe if you use key-based authentication and restrict the SSH user's permissions, but it does increase your attack surface. Always use strong passwords or SSH keys, and consider restricting the allowed commands in the authorized_keys file to only allow port forwarding.

What happens if my home IP address changes?

Since the SSH tunnel originates from your home device, it will automatically re-establish once the network connection is restored. Most SSH clients handle temporary disconnections gracefully, but you may need to restart the tunnel script if the ISP assigns a completely new IP and the previous connection times out.

How do I monitor the bandwidth usage of the tunnel?

You can use tools like nload or bmon on both the local and remote machines to monitor traffic. Since SSH encrypts the payload, you cannot inspect the content, but you can measure the volume of data passing through the tunnel to identify bottlenecks.

Are there alternatives to SSH for creating these tunnels?

Alternatives include Cloudflare Tunnel, ngrok, or ZeroTier. These services often provide easier setup for exposing local services without managing SSH servers, but they may introduce additional latency or depend on third-party uptime compared to a self-hosted SSH tunnel.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More