There is vhost config, which should be reverse proxy to the flask application, and is not working. Below is the vhost config. Flask application is running on port 5000.
Added rewrite in both the context and outside, even then it's not working. Below config always gives the error 500.
vhDomain $VH_NAME
vhAliases www.$VH_NAME
enableGzip 1
enableIpGeo 1
index {
useServer 0
indexFiles index.php, index.html
}
errorlog $VH_ROOT/logs/$VH_NAME.error_log {
useServer 0
logLevel WARN
rollingSize 10M
}
accesslog $VH_ROOT/logs/$VH_NAME.access_log {
useServer 0
logFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
logHeaders 5
rollingSize 10M
keepDays 10
compressArchive 1
}
extprocessor pythonflask1709 {
type proxy
address 127.0.0.1:5000
maxConns 200
pcKeepAliveTimeout 60
initTimeout 20
retryTimeout 0
respBuffer 0
}
scripthandler {
add proxy:pythonflask1709 html
}
module cache {
storagePath /usr/local/lsws/cachedata/$VH_NAME
}
rewrite {
enable 1
autoLoadHtaccess 1
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ HTTPS://127.0.0.1:5000/$1 [P]
}
context / {
type proxy
handler pythonflask1709
addDefaultCharset off
rewrite {
enable 1
autoLoadHtaccess 1
RewriteEngine On
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ HTTP://127.0.0.1:5000/$1 [P]
}
}
For reverse proxy, you have created a Web Server External App named pythonflask1709 which is good. The next step is to set up a context, rewrite rules, or Script Handlers.
Context method
context / {
type proxy
handler demo
addDefaultCharset off
}
Rewrite method
REWRITERULE ^(.*)$ HTTP://pythonflask1709/$1 [P,L,E=PROXY-HOST:WWW.EXAMPLE.COM]
As you can see the above rule, use web server name pythonflask1709
in the rule instead of 127.0.0.1:5000, also please substitute WWW.EXAMPLE.COM with your real domain name.
Both should work, but please do not apply both methods at the same time.
Another solution is to run WSGI APP directly without proxy. More, https://openlitespeed.org/kb/python-wsgi-applications/#Set_up_Flask_with_a_Virtual_Environment
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.