I have a Flask-based website, and working fine when I run on a local PC @ localhost.
I cloned the app into the recently built Ubuntu PC and tried to host the website there. I installed Apache2 and and setup conffile @ (sudo nano /etc/apache2/sites-available/000-default.conf) as follows :
<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
ServerName 10.11.220.58
ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
#DocumentRoot /home/user_name/imageFIFA/frameworks.ai.image-inference
WSGIScriptAlias / /home/user_name/imageFIFA/frameworks.ai.image-inference/app.wsgi
<Directory /home/user_name/imageFIFA/frameworks.ai.image-inference>
Order allow,deny
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 /home/user_name/imageFIFA/frameworks.ai.image-inference/logs/error.Log
CustomLog /home/user_name/imageFIFA/frameworks.ai.image-inference/logs/acess.log comb>
I created app.wsgi in flask project folder (/home/user_name/imageFIFA/frameworks.ai.image-inference) file as follows :
import sys
sys.path.insert(0,'/home/user_name/imageFIFA/frameworks.ai.image-inference')
from interceptor import app as application
My flask as is located at
/home/ad_pgooneti/imageFIFA/frameworks.ai.image-inference
When I run my front-end flask app and test the response with wget, I get the following :
--2022-09-17 12:24:36-- http://localhost:5000/
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:5000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8943 (8.7K) [text/html]
Saving to: 'index.html'
index.html 100%[===================================>] 8.73K --.-KB/s in 0s
2022-09-17 12:24:36 (236 MB/s) - 'index.html' saved [8943/8943]
But If I use the server IP address of wget 10.11.220.58, I get the following :
--2022-09-17 12:29:43-- http://10.11.220.58/
Connecting to 10.11.220.58:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2022-09-17 12:29:43 ERROR 403: Forbidden.
So, I feel that redirection is not working. Apache2 server is running fine when I tested its status :
* apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-09-17 12:02:23 PDT; 29min ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 1392385 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 1392411 (apache2)
Tasks: 55 (limit: 19140)
Memory: 10.4M
CGroup: /system.slice/apache2.service
|-1392411 /usr/sbin/apache2 -k start
|-1392412 /usr/sbin/apache2 -k start
`-1392413 /usr/sbin/apache2 -k start
Sep 17 12:02:23 ImageFIFA systemd[1]: Starting The Apache HTTP Server...
Sep 17 12:02:23 ImageFIFA systemd[1]: Started The Apache HTTP Server.
Any help with why it's not running? The Flask app is running at default port 5000, but I am not sure where am I supposed to do that in conf and app.wsgi files.