I am trying to run multiple dashboards written in Django to run on my server, but am not getting it up and running. Followed this digital ocean tutorial and modified it according to this SO answer. Now everything is up and running and but when am pointing to my URL, it shows Nginx welcome page http://ipaddr/first_dashboard
Below is the gunicorn_fdab.socket
file :
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn_fdab.sock
[Install]
WantedBy=sockets.target
Below is gunicorn_fdab.service
file :
[Unit]
Description=gunicorn daemon for fdab
Requires= gunicorn_fdab.socket
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/opt/fdab
ExecStart=/opt/anaconda/envs/fdab/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn_fdab.sock \
fdab.wsgi:application
[Install]
WantedBy=multi-user.target
Now this is my Nginx conf file :
server {
listen 80;
server_name 111.11.11.111;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /opt/fdab/fdab;
}
location /fdab {
include proxy_params;
rewrite /fdab(.*) $1;
proxy_pass http://unix:/run/gunicorn_fdab.sock;
}
}
Am not able to understand where am doing it wrong.
If am doing curl --unix-socket /run/gunicorn_fdab.sock localhost
, it just returning nothing.
(base) root@virtualserver01:~# curl --unix-socket /run/gunicorn_fdab.sock localhost
(base) root@virtualserver01:~#
Project is stored at /opt/fdab
.
Additional information:
Basically, my project structure for both the project is like this :
/opt/fdab
/fdab
/fdab_dashboard
/opt/pdab
/pdab
/pdab_dashboard
The structure for the project is like this because I intend to have multiple apps in fbad and fdab2(second project name.
EDIT
Updated conf file for Nginx :
server {
listen 80;
server_name 111.11.11.111;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /opt/fdab/fdab;
}
location /fdab {
include proxy_params;
rewrite /fdab/(.*) /$1 break;
proxy_pass http://unix:/run/gunicorn_fbad.sock;
}
location /pdab/static/ {
alias /opt/pdab/pdab/static/;
}
location /pdab {
include proxy_params;
rewrite /pdab/(.*) /$1 break;
proxy_pass http://unix:/run/gunicorn_pdab.sock;
}
}
Now I have added FORCE_SCRIPT_NAME = '/exampleproject'
in both the project.
Now what's happening is that, if am typing in, http://<ipaddr>/fdab/fdab_dashboard
it's working fine, but if am typing in http://<ipaddr>/fdab/
or http://<ipaddr>/pdab/
, am getting redirected to http://<ipaddr>/fdab_dashboard
and http://<ipaddr>/pdab_dashboard
, this is not what is required and moreover, http://<ipaddr>/fdab_dashboard
seems to be working properly. But the fdab
part of the url is missing, once I get into the app after logging in, the url seems fine, maybe because of the FORCE_SCRIPT_NAME = '/fdab'
, but the url http://<ipaddr>/pdab_dashboard
gives me 404 error
page.