Skip to main content

Expose your local Django app to the internet with ngrok

Project description

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.

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_ngrok-0.1.0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

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

django_ngrok-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file django_ngrok-0.1.0.tar.gz.

File metadata

  • Download URL: django_ngrok-0.1.0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.9

File hashes

Hashes for django_ngrok-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02f7f87db8452c1a5646a413f0a9e032c0dd10cc9e6c4aff034a5c844eb558cf
MD5 91e8efae5b68155d39bc700dae57d986
BLAKE2b-256 4737a6c11d7b40c2f4c1d6513c53398782b89fb4f796d73be39d3ffc0b2b0e1b

See more details on using hashes here.

File details

Details for the file django_ngrok-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ngrok-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00d6b2ee34869f9cc2e5fc3d7accbc954845e7f3c6c62c543894ab17ad4f2c95
MD5 63f5903c2241919b287c230952407754
BLAKE2b-256 00f1dfd2125092133ef820253112aa84c47a0ab50aa3046caaf79c3c753c01eb

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