configuring Django Channels for windows in production - django

Please, I need to configure Django Channels on redis-channel-layer on windows IIS in production. It is running very well in development.
I have installed redis, daphne. I have set the IIS as proxy server with URL Rewrite pointing the Inbound to localhost 6379 to redis-layer channels. I used python manage.py runworker. and also started the daphne server with the daphne command.
They all ran very well, but there is no websocket handshake for my url.

Related

How do i run django application without port number

How do i run django application without port number: i had tried Django: Run django app on server without port? but didn't work.
Web services must bind a port on a interface of the system. So, you should specify a port number to run your Django application. The default port number for HTTP is 80, for HTTPS 443. But you can use a custom port between [1-65535]:
For example;
python manage.py runserver 7000
You may try the following:
python manage.py runserver 80
or if you don't have permissions (assuming you are using Linux):
sudo python manage.py runserver 80
Then, you can access your application: http://localhost/
In general, web services need a port to run. If the port used is default http (80) or https (443) port, modern web browsers hide it from seeing in the address bar.
In a development server, you can hide the port(because you don't want to see it anymore) by assigning it to port 80 if it is not used by any other web service in the system(otherwise django will complain):
python manage.py runserver 80
In a production server, you need to use servers like Gunicorn to run your django app in the backend and a web server like Nginx or Apache to serve your backend to external world. In that case, since web servers use http/https ports, no ports will be visible in the browser.

Vagrant networking forwarded_port does not work

I tried to setup sandbox for django development
I have forwarded the port in provision like this
config.vm.network:forwarded_port, host: 4567, guest: 8000
The server on guest started with
System check identified no issues (0 silenced).
March 19, 2015 - 20:50:37
Django version 1.7.7, using settings 'my_site.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
then I open the web browser on host machine and type in
http://127.0.0.1:4567/
Failed to connect to server.
Start the dev server with
python manage.py runserver 0.0.0.0:8000
so that it listens to every interface of port 8000.
You don't need to forward the port on Vagrant for accessing Django server from the host machine. What I usually do is start the server on the guest using
python manage.py runserver 0.0.0.0:8000
and then access it from the host using
"IP_address_of_guest_machine":8000

Visit webpage hosted on ubuntu server in a local network

I have a ubuntu server hosting a web page driven by Python Django, I can access that page by using the following command:elinks http:// 127.0.0.1:8000.
Now if I want to access that same web page on a macbook sharing the same home router with my ubuntu server(local ip: 10.0.0.9), how would I do it? Typing in elinks http:// 10.0.0.9:8000 wouldn't work.
Thanks a lot,
ZZ
Are you running the development server using manage.py?
If so, you should start the server using:
python manage.py runserver 0.0.0.0:8000
This will allow the development server to be visited by ips on all interfaces instead of just localhost.
You need to serve it. There are a number of ways to do this, but my preferred method is to use Nginx as a reverse proxy server for gunicorn. This is a good tutorial for that.

What is the purpose of NGINX and Gunicorn running in parallel?

A lot of Django app deployments over Amazon's EC2 use HTTP servers NGINX and Gunicorn.
I was wondering what they actually do and why both are used in parallel. What is the purpose of running them both in parallel?
They aren't used in parallel. NGINX is a reverse proxy. It's first in line. It accepts incoming connections and decides where they should go next. It also (usually) serves static media such as CSS, JS and images. It can also do other things such as encryption via SSL, caching etc.
Gunicorn is the next layer and is an application server. NGINX sees that the incoming connection is for www.domain.com and knows (via configuration files) that it should pass that connection onto Gunicorn. Gunicorn is a WSGI server which is basically a:
simple and universal interface between web servers and web applications or frameworks
Gunicorn's job is to manage and run the Django instance(s) (similar to using django-admin runserver during development)
The contrast to this setup is to use Apache with the mod_wsgi module. In this situation, the application server is actually a part of Apache, running as a module.
Nginx and Gunicorn are not used in parrallel.
Gunicorn, is a Web Server Gateway Interface (WSGI) server
implementation that is commonly used to run Python web applications.
NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server.
Nginx responsible for serving static content, gzip compression, ssl,
proxy_buffers and other HTTP stuff.While gunicorn is a Python HTTP server that interfaces with both nginx and your actual python web-app code to serve dynamic content.
The following diagrams shows how nginx and Gunicorn interact.

Django & Apache: How to debug on Testing server

I am trying to debug an issue that happens on our testing server. So how do I make it so that I can access our testing server when I start Django by typing:
python manage.py runserver
?
Does it have to pass through Apache? If so, I need to configure Apache somehow but I am not using mod_wsgi and so, don't know how to do this.
Thanks! :)
the test server runs its own web server. the defaul options starts a server on
http://127.0.0.1:8000/, which you can then open in your browser
you can specify an optional ip address/server using
manage.py runserver ip:port
using ip 0.0.0.0 for all network interfaces