ngrok doesn't lift my local django web server - django

I have problems with negrok, it does not raise my local django web server, a few days ago everything worked correctly but a normal day, without having touched anything, it stopped working.
Run the following:
python manage.py runserver
Everything works normally and correctly.
Now I execute the following, in order to raise the local django server:
./ngrok http 8000
ngrok runs correctly without any problem but when accessing the ngrok link, the page is loading and everything is blank and does not work ....
This appears in ngrok:
ngrok by #inconshreveable (Ctrl+C to quit)
Session Status online
Account Julio (Plan: Free)
Version 2.3.34
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://33822c5a.ngrok.io -> http://localhost:8000
Forwarding https://33822c5a.ngrok.io -> http://localhost:8000
Connections ttl opn rt1 rt5 p50 p90
2 0 0.03 0.01 0.20 0.21
HTTP Requests
-------------
GET / 400 Bad Request
GET / 400 Bad Request
And this appears in django:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
September 25, 2019 - 17:23:19
Django version 2.2.2, using settings 'ibme_proyect.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Invalid HTTP_HOST header: '33822c5a.ngrok.io'. You may need to add '33822c5a.ngrok.io' to ALLOWED_HOSTS.
Bad Request: /
[25/Sep/2019 17:25:30] "GET / HTTP/1.1" 400 68119
Invalid HTTP_HOST header: '33822c5a.ngrok.io'. You may need to add '33822c5a.ngrok.io' to ALLOWED_HOSTS.
Bad Request: /
[25/Sep/2019 17:25:38] "GET / HTTP/1.1" 400 68254
I add the ngrok host (33822c5a.ngrok.io) in ALLOWED_HOSTS and stop giving django error, and access the ngrok link and I know that it loads again, it doesn't load the HTML, nothing, everything blank ...
Any solution? :(

try
ALLOWED_HOSTS = ["*"]
this will allow tunneling every ngrok run :)

Related

localhost:8000 working but mywebsite:8000 with etc/hosts modified doesn't work

Everything is in the title: I'm launching my webserver (Django / Python) on port 8000.
/home/olivier/my_venv3.8/bin/python3 /home/olivier/pycharm-2018.1.3/plugins/python/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 40761 --file /home/olivier/projects/evalr/manage.py runserver 8000
pydev debugger: process 5923 is connecting
Connected to pydev debugger (build 193.5662.61)
http://evalr.hqf.fr:8000/fr/assistant/
http://evalr.hqf.fr:8000/fr/sessions/
pydev debugger: process 5935 is connecting
http://evalr.hqf.fr:8000/fr/assistant/
http://evalr.hqf.fr:8000/fr/sessions/
Watching for file changes with StatReloader
Performing system checks...
I've added in my /etc/hosts this line : 127.0.1.1 evalr.hqf.fr and when I ping it, it correctly shows "127.0.0.1"
When I try go on http://evalr.hqf.fr:8000 I get connection refused and when I try to go on http:/localhost:8000 it works.
The problem is that when I try to go on http://evalr.hqf.fr:8000 I dont have any trace on the server side, i.e. it stays here:
System check identified no issues (0 silenced).
January 03, 2020 - 20:41:31
Django version 3.0.2, using settings 'evalr.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
And when I go on http://127.0.0.1:8000/ I get a log of every single access like:
[03/Jan/2020 20:47:42] "GET /fr/sessions/ HTTP/1.1" 302 0
[03/Jan/2020 20:47:42] "GET /fr/login/?next=/fr/sessions/ HTTP/1.1" 200 7031
[03/Jan/2020 20:47:43] "GET /static/vendors/css/all.min.css HTTP/1.1" 200 54456
................ blabla............;
[03/Jan/2020 20:47:43] "GET /favicon.ico HTTP/1.1" 301 0
I've even tried to reboot (even though I'm on Linux, which talks by itself - no reboot needed), so I'm stuck because everything should work fine. What am I missing?
That is because in /etc/hosts it should be 127.0.0.1 instead
Also check the ALLOWED_HOSTS and you could try running it with: python manage.py runserver 0.0.0.0:8000
The fact that you get a connection refused when using the hostname, and do not see any logging from your application, makes me think that you are dealing with DNS caching. My favorite way to test this is using curl, since it can show you both the IP address and response of an HTTP request. Try the following command:
curl -Iv -X GET http://evalr.hqf.fr:8000
Did it resolve to 127.0.0.1? If so, did you get a response? If so, did you see logs in your application?
If the answer to these question is yes, then try to clear the DNS and browser cache.

My ngrok Tunne Status shows reconnecting running on a custom port (4901)

I am running a ngrok on 4901 port.
I am also running a flask webserver on the same port. The idea is that I want to access my local webserver from outside world to do some app testing.
What am I missing ?
NGROK running on 4901
./ngrok 4901
ngrok
Tunnel Status reconnecting Version
1.7/ Web Interface 127.0.0.1:4040
# Conn 0 Avg Conn Time 0.00ms
FLASK:
python webserver.py
* Running on http://0.0.0.0:4901/
127.0.0.1 - - [01/Jul/2016 15:16:02] "GET / HTTP/1.1" 200 -
You are using ngrok version 1.7, which has now been shut down completely. Quoting from their announcement:
As of April 4, 2016, all 1.X sessions were no longer be and service ended completely.
You should be able to upgrade to version 2.0+ and keep using it, although I haven't tried it yet myself.

Nginx Bad Gateway with Django Social Auth and uwsgi

My site is running correctly locally (using the built in runserver), but when running with nginx and uwsgi, I'm getting a Bad Gateway (502) during the django-social-auth redirect.
The relevant nginx error_log:
IPREMOVED - - [11/Oct/2012:12:10:18 +1100] "GET /complete/google/? ..snip .. HTTP/1.1" 502 574 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.26 Safari/537.11"
The uwsgi log:
invalid request block size: 4204 (max 4096)...skip
Thu Oct 11 12:16:46 2012 - error parsing request
Refreshing the Bad Gateway response redirects and logs in correctly. This happens every single time. The nginx and uwsgi logs here have different timing as they were separate requests. The logs are consistent.
This is the first time deploying django to nginx for me, so I'm at a loss as to where to start.
Have you tried increasing the size of the uwsgi buffer:
-b 32768
http://comments.gmane.org/gmane.comp.python.wsgi.uwsgi.general/1171

Django runserver shows HTTP

I have configured nginx to run HTTPS. I also rewrite all the rules so it's running under HTTPS.
But is it true that Django still runs with HTTP internally?
Django version 1.2.1, using settings 'myproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[14/Aug/2012 23:57:04] "GET /app/c HTTP/1.0" 200 4
[14/Aug/2012 23:57:09] "GET /app/c HTTP/1.0" 200 4
Yes. I know my version is way way way outdated.
I checked request.is_secure and it returns True as I am accessing HTTPS.
Correct, internally you will use http to communicate through your proxy server but all your external traffic will use the https method.
To further secure your traffic ensure that you only bind to a local address, or alternatively use a socket to connect between nginx and your application server.
I do hope that you're not using django's development server in production, you should instead use something like gunicorn as your application server.

The logs of POST/GET requests from Django application on Apache

Django development server is really nice, it shows the log of all POST/GET requests as well as other events in real time. Example of logs from Django dev server:
[04/Jul/2012 19:23:27] "GET /static/images/sprites/submit_url_hover.png HTTP/1.1" 200 7088
[04/Jul/2012 19:23:42] "POST /validate_link HTTP/1.1" 200 0
[04/Jul/2012 19:23:44] "POST /download_link HTTP/1.1" 200 0
It's very useful for debugging, figuring out the sources of 500 errors, etc. I've recently deployed my Django app on Apache and looking for logs analogous to that of Django Dev Server on Apache. There is obviously Apache error logs (snippet is below):
[Wed Jul 04 18:37:45 2012] [error] [u'microsoft', u'design', u'logos']
[Wed Jul 04 23:51:01 2012] [error] [client 140.180.6.212] File does not exist: /srv/my_project/app/portnoy/site_media/favicon.ico
But that's not what I want. My site has a simple link submission functionality which works locally (on Django dev server), but is not working on the actual site (running Apache). So seeing the Django dev server style logs on Apache will be really helpful. Any idea where can I look at? Thank in advance and happy 4th!
Check access.log for the apache where you will see each request processed and response sent.
Also, if you have not tried yet, set DEBUG=True in your settings file so django will show you detail error, trace and other useful information.