Apache2 mod_wgsi not working

Reverse proxies, SSL termination, web servers, helm charts, integrations, batch files, anything having to do with installing Mayan.
Post Reply
bwakkie
Posts: 16
Joined: Fri Feb 14, 2020 8:28 pm

Apache2 mod_wgsi not working

Post by bwakkie »

Is this information still somewhere available?
We published some step for setting up HTTPS for Mayan with Apache: https://wiki.mayan-edms.com/index.php?t ... ith_Apache
I am having trouble installing mayan-edms on my virtualhost apache2 webserver under mod_wgsi. An other wgsi website pgadmin4 is running without problems.
I get a 400 error without any clue in the error logs
if I access directly to port 8000 the website comes up which is running through mayan-gunicorn.

Should I not disconnect mayan-gunicorn so that all goes through the mod_wgsi?
Last edited by bwakkie on Sat Aug 29, 2020 10:47 am, edited 2 times in total.
mikeg
Posts: 4
Joined: Tue Dec 10, 2019 4:36 pm

Re: Apache2 mod_wgsi not working

Post by mikeg »

I'm not familiar with setting it up via mod_wgsi, but I was able to get the system setup under https via mod_proxy - my virtualhost code is below:

Code: Select all

<VirtualHost *:443>
    ServerName mayan.mydomain.com
    SSLEngine on
    SSLCertificateFile /etc/apache2/sslcert/b31f5c5a403aadbd.crt
    SSLCertificateKeyFile  /etc/apache2/sslcert/domain.key
    SSLCertificateChainFile  /etc/apache2/sslcert/gd_bundle-g2-g1.crt
    ProxyRequests Off
    ProxyPass / http://127.0.0.1:85/
    ProxyPassReverse / http://127.0.0.1:85/
</VirtualHost>
bwakkie
Posts: 16
Joined: Fri Feb 14, 2020 8:28 pm

Re: Apache2 mod_wgsi not working

Post by bwakkie »

@mikeg thanks for your example. The thing is I already have ssl running. I just need the mod_wsgi part for inside my VirtualHost.
My apache2 conf looks like this:

Code: Select all

> <VirtualHost *:80>¬
> ▸       ServerName www.domain.org¬
> ▸       ServerAlias *.domain.org domain.org¬
> ▸       ErrorLog /var/log/apache2/error.domain.org.log¬
> ▸       Redirect permanent / https://www.domain.org/¬
> </VirtualHost>¬
> ¬
> ¬
> <VirtualHost *:443>¬
> # Let's encrypt ¬
> ▸       SSLCertificateFile /etc/letsencrypt/live/www.domain.org/fullchain.pem¬
> ▸       SSLCertificateKeyFile /etc/letsencrypt/live/www.domain.org/privkey.pem¬
> ▸       Include /etc/letsencrypt/options-ssl-apache.conf¬
> ¬
>         ServerName www.domain.org¬
> ▸       DocumentRoot /var/www/domain.org/htdocs¬
> ▸       ErrorLog /var/log/apache2/error.domain.org.log¬
> ¬
> # Normal website¬
> ▸       <Directory "/var/www/domain.org/htdocs">¬
> ▸       ▸       Options Indexes FollowSymLinks¬
> ▸       ▸       AllowOverride All¬
> ▸       ▸       Require all granted¬
> ▸       </Directory>¬
> ¬
> # www.domain.org/db = pgadmin4 application¬
> ▸       WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/data/.envs/pgadmin4¬
> ▸       WSGIScriptAlias /db /data/.envs/pgadmin4/lib/python3.7/site-packages/pgadmin4/pgAdmin4.wsgi
> ▸       <Directory /data/.envs/pgadmin4/lib/python3.7/site-packages/pgadmin4>¬
> ▸       ▸       WSGIProcessGroup pgadmin¬
> ▸       ▸       WSGIApplicationGroup %{GLOBAL}¬
> ▸       ▸       Order allow,deny¬
> ▸       ▸       Allow from all¬
> ▸       ▸       Require all granted¬
> ▸       </Directory>¬
>
> # mayan document management application¬
> ▸       WSGIDaemonProcess mayan processes=1 threads=25 python-home=/opt/mayan-edms¬
> ▸       WSGIScriptAlias /sources /opt/mayan-edms/lib/python3.7/site-packages/mayan/wsgi.py¬
> ▸       <Directory /opt/mayan-edms/lib/python3.7/site-packages/>¬
> ▸       ▸       WSGIProcessGroup mayan¬
> ▸       ▸       WSGIApplicationGroup %{GLOBAL}¬
> ▸       ▸       Order allow,deny¬
> ▸       ▸       Allow from all¬
> ▸       </Directory>¬

> ▸       Alias /sources/static /opt/mayan-edms/media/static/¬
>     ▸   <Location "/sources/static">¬
>         ▸       SetHandler None¬
>     ▸   </Location>¬

> </VirtualHost>¬
If I go to http://www.domain.org:8000 it is working but that is because it is still served by gunicorn but it is not behind the ssl.
If I try to access it thought apache2 through https://www.domain.org/docs I get nothing.
How can I get the above settings working?

I was also testing to use the proxy instead ( by uncommenting the mod_wsgi part above for mayan) and adding the following part to the apache conf:

> ProxyPreserveHost On¬
> ProxyRequests Off¬
> ProxyPass /sources http://localhost:8000/¬
> ProxyPassReverse /sources http://localhost:8000/

I can enter https://www.domain.org/sources but I do get only text as static files aren't uploading as it is still requesting /static/.. and not /docs/statics/. This is probably because of absolute links within mayan not being rewritten by ProxyPass and so breaks the application.

Any tips are welcome :)
bwakkie
Posts: 16
Joined: Fri Feb 14, 2020 8:28 pm

Re: Apache2 mod_wgsi not working

Post by bwakkie »

Solved it almost
I just needed to link the static folder to the DocumentRoot:

My DocumentRoot withing the apache config directs to:
DocumentRoot /var/www/wakkie.org/htdocs

inside the htdocs folder I pointe the static folder to the static folder within the mayan environment:
# cd /var/www/mydomain.com/htdocs
# ln -s /data/.envs/mayan3.7/media/static/ static
# ll static
> root@server:/var/www/wakkie.org/htdocs# ll static
> lrwxrwxrwx 1 root root 34 aug 28 09:01 static -> /data/.envs/mayan3.7/media/static/

Now I can see all static files, menus etc. if there is a login cookie already. But the view area keeps staying empty as the application is not adding the /source/ infront of the internal links. Ones I logout I get a 502 Proxy error
Post Reply