Skip to main content

A Django plugin that allows ssh remote tunnels.

Project description

django-ssh-tunnel-proxy

Opens an ssh tunnel so your local development server can be accessed remotely

Quick start

  1. Install with pip install django-ssh-tunnel-proxy
  2. Add sshtunnelproxy to INSTALLED_APPS
  3. Set the settings described below
  4. Start a dev-server using python manage.py runserver
  5. Open a tunnel using python manage.py opensshtunnelproxy
  6. Visit the URL displayed in your terminal

Context manager

Create a temporary tunnel using the context manager

from sshtunnelproxy import tunnel

with tunnel() as remote_url:
    pass  # do something

Available settings

SSH_TUNNEL_USER: str = ''
"""The SSH user to use for the tunnel. default: `''`"""

SSH_TUNNEL_PASSWORD: str = ''
"""The SSH password to use for the tunnel. default: `''`"""

SSH_TUNNEL_PORT_RANGE: tuple[int, int] = (24000, 24999)
"""The range of ports to use for the tunnel. default: `(24000, 24999)`"""

SSH_TUNNEL_HOST: str = ''
"""The host to tunnel to. default: `''`"""

SSH_TUNNEL_URL_GENERATOR: Callable[[int], str] = lambda port: f"http://{SSH_TUNNEL_HOST}:{port + 1}"
"""
The function to generate the tunnel URL.
Takes the remote port as an argument and returns the URL at which the tunnel can be accessed.
default: `lambda port: f'http://{HOST}:{port + 1}'`
"""

Remote server

For this to work, you need a remote web server to reverse-proxy the tunneled port.

What else

Make sure to add SSH_TUNNEL_HOST to your ALLOWED_HOSTS.
Also, SESSION_COOKIE_SECURE = False must be set, or else you won't be able to log in.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_ssh_tunnel_proxy-1.0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ssh_tunnel_proxy-1.0.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file django_ssh_tunnel_proxy-1.0.2.tar.gz.

File metadata

  • Download URL: django_ssh_tunnel_proxy-1.0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for django_ssh_tunnel_proxy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b9da64c5512f4876276df8be3b0e50393f5ce06902b482c57ac1a19f3591705d
MD5 018c7040f1a84f7426503f00e36aff36
BLAKE2b-256 cd1a3955c9ba21e04b6c05741af918483033af3338bb23fea6da0b1f19d44098

See more details on using hashes here.

File details

Details for the file django_ssh_tunnel_proxy-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ssh_tunnel_proxy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab81de399b151ac11a81f93956746430a909be50927204b5f4ce914da79803d4
MD5 c61d6764ad0e30d1289b0dcd900a3885
BLAKE2b-256 24cf41768f40baba2ac5a55c88d4b084133cfd2b3b66906f9e55d6994ad7fb0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page