As it follows from the title I'm trying to deploy a django application with the above-mentioned stack of technologies. We're using django for the serverside and angular 6 for the frontend. I'm doing this for the first time in my life and there are some things that are not quite clear to me, so correct me if I say something weird.
- I'm using Nginx to serve static. The config looks as follows:
serverside_nginx_static.conf
server {
listen [::]:80 ;
root /home/user/serverside_deployment/static/;
index index.html index.htm index.nginx-debian.html;
client_max_body_size 4G;
access_log /home/user/serverside_deployment/logs/nginx-access.log;
error_log /home/user/serverside_deployment/logs/nginx-error.log;
location / {
try_files $uri $uri/ /index.html;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/user/serverside_deployment/static/;
}
1.1 I'm also using Nginx to communicate with gunicorn which in turn communicates with the django app itself. The appropriate config looks like this:
serverside_nginx.conf
upstream mtt_server {
server unix:/home/user/serverside_deployment/serverside_env/run/gunicorn.sock fail_timeout=0;
}
server {
listen 8000;
server_name 192.168.10.98;
client_max_body_size 4G;
access_log /home/user/serverside_deployment/logs/nginx-access.log;
error_log /home/user/serverside_deployment/logs/nginx-error.log;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://mtt_server;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/user/serverside_deployment/static/;
}
}
- I'm using supervisor to start the gunicorn bash script.
So this configuration does work or to be precise the REST does but the websockets do not. I'm getting 404 Not Found saying that the defined channels cannot be found. Unless I'm mistaken in order to solve this issue I need to deploy django channels with Daphne as the interface server.
This manual seems to be a tad obsolete but give an idea as to what the process of deployment should look like. However my case is more complicated and I can't make out how I should connect the daphne part to what I already have. I just need to make the websockets work and I don't think I fully understand why it cannot find the channels open.
It's an interesting task but unfortunately there's not too much time left to solve it so I would appreciate any help.
P.S.
The static is somewhat in the wrong location at the moment, but it will be moved to the right place later.
EDIT:
What is weird is that everything works fine when ran on the dev server.
EDIT 2:
Any ideas?