Skip to content

Latest commit

 

History

History
95 lines (68 loc) · 3.89 KB

mac-ngrok.md

File metadata and controls

95 lines (68 loc) · 3.89 KB

macOS 13.x (High Sierra): Using ngrok

SI 664 autograders rely on ngrok to provide your laptop with a temporary HTTP tunnel and a temporary internet domain in which to communicate with the web server hosting the autograder service.

Create an account

Visit ngrok, click the "SIGN UP" button, and create an account.

Download

On the Setup and Installation page and choose the appropriate ngrok archive to download:

macOS: https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip

Install

Move the *.zip archive to your user's home folder and then open the terminal and issue the unzip command:

kathrada:~ arwhyte$ unzip /path/to/ngrok-stable-darwin-amd64.zip

Copy Auth Token

Copy the authtoken command from the ngrok "Setup & Installation" page and run it in the terminal. This action will add the token to your ngrok.yml configuration file.

kathrada:~ arwhyte$ ./ngrok authtoken 3X78JfAiBvdUMSiKEeJNf_2ptioVDLB3FFZw6uu1Z32

Open a Tunnel on Port 8000

kathrada:~ arwhyte$ ./ngrok http 8000

ngrok by @inconshreveable                                                                                                                                                                   (Ctrl+C to quit)

Session Status                online
Account                       Anthony Whyte (Plan: Free)
Version                       2.2.8
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://be5bc9dd.ngrok.io -> localhost:8000
Forwarding                    https://be5bc9dd.ngrok.io -> localhost:8000

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

Type "Control" + "C" (CTRL+C) to close the tunnel.

⚠️ Remember that each time you start ngrok, it will assign you a different random address.

ngrok Inspector

Once you have opened a tunnel open a new browser tab and visit http://localhost:4040 to review tunnel activity. You can inspect HTTP headers and responses as well as replay a request.

Tweek Django Settings

Open mysite settings.py and add a wildcard character ('*') to the ALLOWED_HOSTS list property.

ALLOWED_HOSTS = ['*']

Otherwise you are likely to encounter a DisallowedHost exception when using the ngrok temporary domain.

Check ngrok Connection

Construct the ngrok URL by removing the "http://localhost:8000" and replacing it with the ngrok-provided URL:

example: http://localhost:8000/polls/ to https://be5bc9dd.ngrok.io/polls/

Assignments

Whenever you encounter an SI 664 assignment that involves an autograder do the following:

  1. Read the exercise directions carefully.
  2. Activate your Django project virtual environment.
  3. Start the Django development server.
  4. Perform the exercise, making changes to your Django app instance as required.
  5. Start an ngrok tunnel.
  6. When interacting with the autograder over HTTP replace http://localhost:8000 with the ngrok domain.
  7. Make frequent use of the ngrok inspector to monitor the HTTP request/response cycle.
  8. After submitting your assignment and receiving a grade close the tunnel.

ngrok Documentation

The ngrok online documentation is well-written and worth exploring. You can also access the documentation from the terminal:

kathrada:~ arwhyte$ ./ngrok help

License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.