qwc-services / qwc-db-auth

QWC authentication service based on local user DB
MIT License
0 stars 13 forks source link

Deploy service with uwsgi #4

Closed benoitblanc closed 4 years ago

benoitblanc commented 4 years ago

Hello,

I am trying since few days to use qwc-services and authentication. I have my own QGIS Server instance and QWC2 app running in my localhost.

I created my db like in https://github.com/qwc-services/qwc-config-db.

Then I created virtual environment and install requirements in qwc-db-auth.

virtualenv --python=/usr/bin/python3 .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install uwsgi
export CONFIG_PATH=../qwc-docker/demo-config/

I started service with uwsgi and I created location in nginx conf

uwsgi --http :9096 --wsgi-file server.wsgi
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html/;

        index index.html index.htm index.nginx-debian.html;

        server_name localhost;

        proxy_redirect     off;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        location /auth/ {
                proxy_pass http://localhost:9096/;
        }
...
}

I can access to my QWC2 application with http://localhost and I have access to qwc-db-auth templates files if I enter URL http://localhost/auth/login or http://localhost/auth/password/new. I can also log in with admin user.

The problem is that I can not navigate through templates files because there are wrong URLs (http://localhost/password/new) and 404 error occurs.

Is there something I am missing for the configuration of my service(s) ?

Any help to configure qwc-services without docker is welcome :smiley:

Thanks,

Benoît

benoitblanc commented 4 years ago

Hi,

I managed to start my wsgi service and navigate through templates files.

I added --mount option when I start service with UWSGI :

uwsgi --mount /auth=server.py --callable app --manage-script-name --socket /tmp/dbauth.sock --chmod-socket=666

And I modified nginx location with uwsgi params :

...
        location /auth/ {
                include uwsgi_params;
                uwsgi_pass unix:/tmp/dbauth.sock;
        }
...

Hope it could help