Skip to main content

django-ngrok

Expose your local Django app to the internet with ngrok

Quick start

  1. Install with pip:
pip install django-ngrok
  1. Add django-ngrok to INSTALLED_APPS in your Django settings file:
INSTALLED_APPS = [
    ...
    'django_ngrok',
]
  1. Set the NGROK_AUTHTOKEN environment variable to your ngrok authtoken:
export NGROK_AUTHTOKEN="your-ngrok-authtoken"
  1. Run python manage.py runserver_ngrok to start a django development server and an ngrok tunnel pointing to the server address. You should expect to see the following output:
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
December 13, 2024 - 19:58:42
Django version X.Y.ZZ, using settings 'your.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

ngrok forwarding to http://127.0.0.1:8000 from ingress url: https://your-ngrok-domain.ngrok-free.app

Configuration

django-ngrok uses the forward method from ngrok-python to create a tunnel to the Django development server. If you are using a simple setup, no configuration is necessary, and you can get up-and-running by following the quick start.

For a more explicit setup, you can add the NGROK_CONFIG setting to your Django settings file. All options below are documented here. If you have any questions about how to use these options, please direct them to the ngrok-python maintainers.

NGROK_CONFIG = {
    # session configuration
    "authtoken": str,
    "authtoken_from_env": True | False,  # Defaults to True
    "app_protocol": str,
    "session_metadata": str,
    # advanced session connection configuration
    "server_addr": str,
    "root_cas": str,
    "session_ca_cert": str,
    # listener configuration
    "metadata": str,
    "domain": str,
    "schemes": list[str],
    "proto": str,
    "proxy_proto": str,
    "labels": str,
    # module configuration
    "basic_auth": list[str],
    "circuit_breaker":0.1,
    "compression":True,
    "allow_user_agent": str,
    "deny_user_agent": str,
    "allow_cidr": str,
    "deny_cidr": str,
    "crt": bytes,  # I assume bytes, docs don't specify, haven't tested it.
    "key": bytes,
    "mutual_tls_cas": bytes,
    "oauth_provider": str,
    "oauth_allow_domains": list[str],
    "oauth_allow_emails": list[str],
    "oauth_scopes": list[str],
    "oauth_client_id": str,
    "oauth_client_secret": str,
    "oidc_issuer_url": str,
    "oidc_client_id": str,
    "oidc_client_secret": str,
    "oidc_allow_domains": list[str],
    "oidc_allow_emails": list[str],
    "oidc_scopes": list[str],
    "policy": str,
    "request_header_remove": str,
    "response_header_remove": str,
    "request_header_add": str,
    "response_header_add": str,
    "verify_upstream_tls": True | False,
    "verify_webhook_provider": str,
    "verify_webhook_secret": str,
    "websocket_tcp_converter": True | False,
}

Contributing

Contributions and feedback are welcome! A contribution guide is upcoming, but if you have any questions, please feel free to open an issue or reach out directly.

Metadata

Release files for django-ngrok 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-ngrok 0.1.0
File Size Uploaded
django_ngrok-0.1.0.tar.gz 24.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-ngrok 0.1.0
File Interpreter ABI Platform
django_ngrok-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / django_ngrok-0.1.0.tar.gz

Download URL django_ngrok-0.1.0.tar.gz
Size 24.2 kB
Tags Source
SHA-256 checksum
How to use checksums
02f7f87db8452c1a5646a413f0a9e032c0dd10cc9e6c4aff034a5c844eb558cf
BLAKE2b-256 checksum
How to use checksums
4737a6c11d7b40c2f4c1d6513c53398782b89fb4f796d73be39d3ffc0b2b0e1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.9

Release files / django_ngrok-0.1.0-py3-none-any.whl

Download URL django_ngrok-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00d6b2ee34869f9cc2e5fc3d7accbc954845e7f3c6c62c543894ab17ad4f2c95
BLAKE2b-256 checksum
How to use checksums
00f1dfd2125092133ef820253112aa84c47a0ab50aa3046caaf79c3c753c01eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page