Arch - Apache - Flask : Help needed


#1

“”“
My domain is: valdres.hovrud.com
I ran this command: certonly --webroot -w /var/www -d valdres.hovrud.com
It produced this output: 403
My operating system is (include version): Linux hmepisrv 4.9.23-1-ARCH
My web server is (include version): apache-2.4.25-1 & python-flask-0.12.1-1
My hosting provider, if applicable, is: Private
I can login to a root shell on my machine (yes or no, or I don’t know): Yes
I’m using a control panel to manage my site (no, or provide the name and version of the control panel): No
”""

I am currently running a Flask app through mod_wsgi on a raspberry pi at home.

The app is located in /home/apache/serverpi following the usual Flask- layout (FlaskApp folder with static/ templates/ etc…) and is running as the user and group ‘apache’ in httpd.conf

I am confused as to where my ‘webroot’ folder is, or how i set this up correctly. As i understand, all the content in the ‘webroot’ will be accessible, and this is how certbot checks if the server is indeed mine.
If i have a file ‘foo.png’ in webroot it will be accessible throug ‘mydomain.com/foo.png’?
Obviously i dont want all my source-files accessible, only the static files. This does work with ‘mydomain.com/static/foo.png’ for files in the static folder.

I feel like i have tried everything, but i cant get my server to serve files from wherever I choose to define my “webroot”.
I have tried different directories ( ‘/var/www’ , ‘/home/apache/serverpi’ ‘/home/apache/serverpi/FlaskApp/webroot’) by changing the options in ‘httpd.conf’.
Here is the bottom of my latest attempt, where i created a new webroot-folder to serve the files:

# Mod_wsgi
LoadModule wsgi_module modules/mod_wsgi.so


# serverpi conf
<VirtualHost *>
    ServerAdmin henrik.h@online.no
    ServerName valdres.hovrud.com

    WSGIDaemonProcess flaskapp user=apache group=apache threads=3
    WSGIScriptAlias / /home/apache/serverpi/flaskapp.wsgi

    DocumentRoot /home/apache/serverpi/FlaskApp/webroot
    <Directory /home/apache/serverpi/FlaskApp/webroot>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    <Directory /home/apache/serverpi>
        WSGIProcessGroup flaskapp
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>

</VirtualHost>

No matter where i place it, I cant seem to get access to the files i place in this directory, or get certbot to successfully authenticate.
Any tips is greatly appreciated as I have little experience with Apache and how it works.


#2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.