InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Ssh tutorials

  • Create ssh public/private keys on command line
  • Check if an ssh key has passphrase
  • Connect to mysql server using ssh port forwarding
  • Display keys added to ssh-agent using ssh-add
  • Find authentication methods an ssh server supports
  • Generate ssh public key from private key
  • Linux - how to enable password login on ssh server
  • Linux - ssh agent forwarding when using bastion host
  • Prevent ssh session freezing due to timeout
  • Remove passphrase from ssh private key
  • Ssh port forwarding to surf a site from different location
 
  • Home
  • > Tutorials
  • > Linux/Unix Command Line
  • > SSH

How to use ssh port forwarding to surf a site from different location

By admin | Last updated on Jan 27, 2016

Sometimes we want to access a web site from a different location or ip to see how various things appear on the site. There can be multiple reasons for this:

  1. For debugging purpose you want to see how your sites appear from a different country/location.
  2. For some reason you ISP is using wrong network route to reach a site and this site is unavailable due to some network congestion on a specific route.

These instructions need you to have access to some machine in desired location/country with ssh installed. I’m using AWS EC2 instance in US for this. Here are the steps to do it on mac or Linux and using Firefox or Chrome. For Windows, similar instructions can be followed using other ssh clients.

SSH setup

First ssh to the server using this command.

ssh -D 12345 -i /path/to/ssh_key_file_name 12345 machinename.com

In case you want to login using password, you can skip -i and /path/to/ssh_key_file_name. This will start listening to port 12345 (you can pick any other port also) on localhost and setup a SOCKS proxy. This means that any traffic coming to port 12345 on localhost will be tunneled though ssh to the server and server will forward it to intended destination.

Firefox Settings

To change firefox settings follow these steps:

  1. First open firefox preference panel as shown below:
    mac-firefox-preferences-menu
  2. In preference click on Advanced tab -> network sub tab -> Settings as shown below:
    mac-firefox-network-settings-link
  3. This will open up proxy setting panel as shown below.
    mac-firefox-proxy-settingsSelect manual proxy configuration and enter localhost in SOCKS Host with port 12345 (or whatever port you used in ssh port forwarding above). By default no proxy for localhost and 127.0.0.1 is set. Leave it unchanged.
  4. To validate if you visit show my ip address, you will see IP address which is same as the IP of the server you connected to using ssh above. You can also note your IP before changing SOCKS settings to verify if it has changed.

Chrome setup

Chrome setup can be done using command line. To do this first close all chrome browsers and then start chrome with following command:

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"  --proxy-server="socks5://localhost:12345"

In case you have not installed Chrome at standard location, change the path accordingly. This will start Google chrome and will use SOCKS proxy for web surfing.

Notes on HTTP headers

Since SOCKS proxy is at a lower level than HTTP proxy, The HTTP headers are not modified when the server connects to the desired site. In case of other proxies Some http headers (e.g. X-Forwarded-For) may get changed.

Suggested posts:

  1. How to migrate wordpress from root to sub directory
  2. How to connect to mysql server using ssh port forwarding
  3. How to setup ssl (https) for your site on Ubuntu Linux
  4. Mongo – cli quick start guide
  5. Linux Systemd/Systemctl quick start guide
  6. How to delete files starting with dash/hyphen
  7. How to convert HTML canvas to png image using javascript
  8. Install google camera on Asus m1 max pro
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Linux Interview Questions, Linux/Unix Command Line, Networking, SSH, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress