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
- Install with
pip install django-ssh-tunnel-proxy - Add
sshtunnelproxytoINSTALLED_APPS - Set the settings described below
- Start a dev-server using
python manage.py runserver - Open a tunnel using
python manage.py opensshtunnelproxy - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_ssh_tunnel_proxy-1.0.1.tar.gz.
File metadata
- Download URL: django_ssh_tunnel_proxy-1.0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
280b81859962ee79b7a16a836a034dd2b9ae91fb7232218ec90c621e81807acd
|
|
| MD5 |
522a5ac128cc859f7596554b89b99dee
|
|
| BLAKE2b-256 |
f80cdab7d414ffd2a6d0b68ceadd4a38bc24a62e2e8ff96e11372927d6b83458
|
File details
Details for the file django_ssh_tunnel_proxy-1.0.1-py3-none-any.whl.
File metadata
- Download URL: django_ssh_tunnel_proxy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5eda904f96504d5b993779c59b7ec7b45f3d32c12e6028fe0b8f56773da6b3ed
|
|
| MD5 |
7d682a42771b68f8fea5dcc37420954a
|
|
| BLAKE2b-256 |
3c540151373596d4923fafe0b8d7870246d2203c4ebdf169db75ed79d665e834
|