Hello Graham,
Thanks for pointing this out. I have now corrected it so the configuration file
looks as below. The problem however still persists.
cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port
that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
WSGIDaemonProcess flaskapp threads=5
WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi
WSGIApplicationGroup %{GLOBAL}
<Directory flaskapp>
WSGIProcessGroup flaskapp
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
#Header set Access-Control-Allow-Origin "*"
</VirtualHost>
Best regards,
Jian
> Den 10. okt. 2021 kl. 23.23 skrev Graham Dumpleton
> <[email protected]>:
>
> For a start, this is wrong:
>
> <Directory flaskapp>
> WSGIProcessGroup flaskapp
> WSGIApplicationGroup %{GLOBAL}
> Order deny,allow
> Allow from all
> </Directory>
>
> It should be:
>
> <Directory /var/www/html/flaskapp>
> WSGIProcessGroup flaskapp
> Require all granted
> </Directory>
>
> Graham
>
>> On 11 Oct 2021, at 7:09 am, Jian Wu <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Dear Graham,
>>
>>
>> I am following this guide
>> https://asdkazmi.medium.com/deploying-flask-app-with-wsgi-and-apache-server-on-ubuntu-20-04-396607e0e40f
>>
>> <https://asdkazmi.medium.com/deploying-flask-app-with-wsgi-and-apache-server-on-ubuntu-20-04-396607e0e40f>
>> to deploy a flask app together with apache2 and mod-wsgi. My intension is
>> being able to perform a request post call from another server over the
>> internet to my server running flask.
>>
>> It seems that the author suggests to install mod-wsgi using the below
>> command. I am not sure if that package is supported?
>>
>> sudo apt-get install libapache2-mod-wsgi-py3
>>
>> I followed the instruction, and when I typed in my local IP address on a
>> browser I received a message saying “Forbidden you don’t have the permission
>> to access this ressource Apache 2.4.46 (Ubuntu server at 192.168.0.179 port
>> 80).
>>
>> Hardware:
>> - Raspberry Pi 4 with Ubuntu 20.04. My local IP is 192.168.0.179
>> - Router configuration: As seen in the picture below, I have forwarded port
>> 22 external to internal 22 and external port 81 to internal port 80.
>> <Indsat grafik-1.tiff>
>>
>> These ports are opened on my Ubuntu server
>> (env) hd2900@hd2900:/etc/apache2/sites-available$ sudo ufw status
>> [sudo] password for hd2900:
>> Status: active
>>
>> To Action From
>> -- ------ ----
>> 22/tcp ALLOW Anywhere
>> OpenSSH ALLOW Anywhere
>> Apache Full ALLOW Anywhere
>> 81/tcp ALLOW Anywhere
>> 22/tcp (v6) ALLOW Anywhere (v6)
>> OpenSSH (v6) ALLOW Anywhere (v6)
>> Apache Full (v6) ALLOW Anywhere (v6)
>> 81/tcp (v6) ALLOW Anywhere (v6)
>>
>> My Apache2 configuration file:
>> (env) hd2900@hd2900:~/Documents/Python/hd2900TakeawayPrint$ cat
>> /etc/apache2/sites-enabled/000-default.conf
>> <VirtualHost *:80>
>> # The ServerName directive sets the request scheme, hostname and port
>> that
>> # the server uses to identify itself. This is used when creating
>> # redirection URLs. In the context of virtual hosts, the ServerName
>> # specifies what hostname must appear in the request's Host: header to
>> # match this virtual host. For the default virtual host (this file) this
>> # value is not decisive as it is used as a last resort host regardless.
>> # However, you must set it for any further virtual host explicitly.
>> #ServerName www.example.com <http://www.example.com/>
>>
>> ServerAdmin webmaster@localhost
>> DocumentRoot /var/www/html
>> WSGIDaemonProcess flaskapp threads=5
>> WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi
>> WSGIApplicationGroup %{GLOBAL}
>>
>> <Directory flaskapp>
>> WSGIProcessGroup flaskapp
>> WSGIApplicationGroup %{GLOBAL}
>> Order deny,allow
>> Allow from all
>> </Directory>
>>
>> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
>> # error, crit, alert, emerg.
>> # It is also possible to configure the loglevel for particular
>> # modules, e.g.
>> #LogLevel info ssl:warn
>>
>> ErrorLog ${APACHE_LOG_DIR}/error.log
>> CustomLog ${APACHE_LOG_DIR}/access.log combined
>>
>> # For most configuration files from conf-available/, which are
>> # enabled or disabled at a global level, it is possible to
>> # include a line for only one particular virtual host. For example the
>> # following line enables the CGI configuration for this host only
>> # after it has been globally disabled with "a2disconf".
>> #Include conf-available/serve-cgi-bin.conf
>> #Header set Access-Control-Allow-Origin "*"
>> </VirtualHost>
>>
>> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
>>
>>
>> My Flask app folder structure:
>> (env) hd2900@hd2900:~/Documents/Python/hd2900TakeawayPrint$ ls -la
>> total 32
>> drwxrwxr-x 4 hd2900 hd2900 4096 Oct 10 18:23 .
>> drwxrwxr-x 3 hd2900 hd2900 4096 Oct 10 18:04 ..
>> drwxrwxr-x 4 hd2900 hd2900 4096 Oct 10 18:08 env
>> -rw-rw-r-- 1 hd2900 hd2900 249 Oct 10 18:23 flaskapp.py
>> -rw-rw-r-- 1 hd2900 hd2900 96 Oct 10 18:23 flaskapp.wsgi
>> drwxrwxr-x 8 hd2900 hd2900 4096 Oct 10 18:23 .git
>> -rw-r--r-- 1 root root 5 Oct 10 18:05 .gitignore
>> -rw-rw-r-- 1 hd2900 hd2900 69 Oct 10 18:04 README.md
>>
>> flaskapp.wsgi content
>> cat flaskapp.wsgi
>> import sys
>> sys.path.insert(0, '/var/www/html/flaskapp')
>>
>> Flaskapp.py content
>> cat flaskapp.py
>> # flaskapp.py
>> # This is a "hello world" app sample for flask app. You may have a different
>> file.
>> from flask import Flask
>> app = Flask(__name__)
>> @app.route('/')
>> def hello_world():
>> return 'Hello from Flask!'
>> if __name__ == '__main__':
>>
>> I don’t know how to troubleshoot this problem further, and I hope for your
>> advice.
>>
>> Thanks in advance!
>>
>> Best regards,
>> Jian
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "modwsgi" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected]
>> <mailto:[email protected]>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/modwsgi/2BCCBE0B-7ECB-462D-998D-B0048679D76B%40gmail.com
>>
>> <https://groups.google.com/d/msgid/modwsgi/2BCCBE0B-7ECB-462D-998D-B0048679D76B%40gmail.com?utm_medium=email&utm_source=footer>.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/modwsgi/DA44D477-D5A6-4843-94BD-D2934DB8F9FE%40gmail.com
>
> <https://groups.google.com/d/msgid/modwsgi/DA44D477-D5A6-4843-94BD-D2934DB8F9FE%40gmail.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/modwsgi/85F8B0E7-909C-4FE5-B9E4-EE861298E63A%40gmail.com.