I can't see that you would want:
--proxy-mount-point /ndapps http://localhost:8001/ndapps/
<http://localhost:8001/ndapps/>
but you may want:
--mount-point /ndapps
If you don't do that, the backend will think it lives at / rather than sub URL
of /ndapps and unless you hard code routes to know about the sub URL, generated
links from pages will likely be wrong as they will not include the mount point.
Even if you add this and generated links don't include the mount point, it is
likely because you are generating them the wrong way. Flask has some helper
function you can use in code and templates to have it generate URLs for you.
When you use it, it will include the mount point in the generated URLs.
When mounting at a sub URL, you may have have to be careful with the route for
the root of the site in Flask. It needs to be defined so as to do trailing
slash redirection. That is, if the request comes through as /ndapps, you want
Flask to redirect that to /ndapps/ first. If you don't do that, you can have
also sorts of issues with relative links generated from home page of the site.
As to static files, what is hosting them? The backend mod_wsgi-express? If yes,
how?
Graham
> On 4 Mar 2018, at 11:10 am, neilD <[email protected]> wrote:
>
> I have previously set up a successful virtual environment to host a Flask
> app, and proxied to it so that I could use a python version different than
> that of the main Apache mod_wsgi as described HERE
> <https://groups.google.com/forum/#!topic/modwsgi/MRKdrcgRN6E>.
>
>
>
> RRFexpire has been working great for a couple months and now I want to deploy
> a new Flask app. This will replace and not supplement RRFexpire, so there
> will only be one VirtualHost defined in httpd.conf. Other existing Flask
> apps are just defined in the main body of the Apache config, for example:
>
>
> WSGIDaemonProcess Repeaters python-home=/usr/local/bin/anaconda3 user=apache
> group=apache threads=5
> WSGIScriptAlias /reticlerepeat /var/www/flask/repeaters/repeaters.wsgi
> <Directory /var/www/flask/repeaters>
> WSGIProcessGroup Repeaters
> WSGIApplicationGroup %{GLOBAL}
> Order deny,allow
> Allow from all
> </Directory>
>
>
> My project is structured as
>
> /home/neild/public_html/ndapps/
>
> ndapps.wsgi
>
> ndapps.py
>
> venv/
>
> static/
>
> style.css
>
> klarity.png
>
> templates/
>
> base.html
>
> index.html
>
>
>
> I want this to be accessed at http://deptserver.city.micron.com/ndapps
> <http://deptserver.city.micron.com/ndapps>
> I setup mod_wsgi-express exactly as before:
>
> mod_wsgi-express setup-server ndapps.wsgi --port=8001 --user apache --group
> apache --server-root=/etc/mod_wsgi-express-8001
>
>
> As well as updating Apache exactly as I had it previously configured:
>
>
>
>
> <VirtualHost *:80>
> ServerName deptserver.city.micron.com
> ProxyPass /ndapps http://localhost:8001/
> ProxyPassReverse /ndapps http://localhost:8001/
> RequestHeader set X-Forwarded-Port 80
> </VirtualHost>
>
> And my ndapps.wsgi contains only
>
>
>
> import sys
> sys.path.insert(0, '/home/neild/public_html/ndapps')
> from ndapps import app as application
>
>
> The app works beautifully when directly accessed via the port number as
> http://deptserver.city.micron.com:8001
> <http://deptserver.city.micron.com:8001/>
>
> However, at http://deptserver.city.micron.com/ndapps
> <http://lelrdaapps01.lehi.micron.com/ndapps>, the page is displayed without
> styling, and when I enter info and submit a form, the next page is not found.
>
>
> “The requested URL /display was not found on this server.”
>
>
>
> And the error log shows
>
>
> [error] [client 10.xxx.xxx.166] File does not exist: /var/www/html/display,
> referer: http://deptserver.city.micron.com/ndapps/
> <http://lelrdaapps01.lehi.micron.com/ndapps/>
> I have tried many different server-setup configurations, including all
> combinations of
>
>
>
>
> --trust-proxy-header X-Forwarded-Host
> --trust-proxy-header X-Forwarded-Port
> --trust-proxy-header X-Forwarded-For
> --trust-proxy-header X-Forwarded-Scheme
> -–document-root static
> -- proxy-mount-point /ndapps http://localhost:8001/ndapps/
> <http://localhost:8001/ndapps/>
>
>
> Following along with examples from the blog link
> <http://blog.dscpl.com.au/2015/07/redirection-problems-when-proxying-to.html>,
> I can access the files in the static folder directly, but trying
>
> http:// <http://lelrdaapps01.lehi.micron.com/ndapps/static>deptserver.city
> <http://lelrdaapps01.lehi.micron.com/ndapps>.micron.com/ndapps/static
> <http://lelrdaapps01.lehi.micron.com/ndapps/static> gives me a 404 error and
> redirects me to http://
> <http://lelrdaapps01.lehi.micron.com/ndappsstatic/>deptserver.city
> <http://lelrdaapps01.lehi.micron.com/ndapps>.micron.com/ndappsstatic/
> <http://lelrdaapps01.lehi.micron.com/ndappsstatic/>
>
> Then I tried to add trailing slashes in ProxyPass and ReverseProxyPass
> directives in Apache config. This did not help, and just redirects me from
> http:/ <http://lelrdaapps01.lehi.micron.com/ndapps/static>/deptserver.city
> <http://lelrdaapps01.lehi.micron.com/ndapps>.micron.com/ndapps/static
> <http://lelrdaapps01.lehi.micron.com/ndapps/static> to http://
> <http://lelrdaapps01.lehi.micron.com/ndapps/static/>deptserver.city
> <http://lelrdaapps01.lehi.micron.com/ndapps>.micron.com/ndapps/static/
> <http://lelrdaapps01.lehi.micron.com/ndapps/static/>
>
> When testing with curl command, I do notice that it connects to a proxy on
> port 8080 before the GET. Could this be confusing mod_wsgi-express?
>
>
> I have been working on this for two weeks and feel stuck by wanting this
> fixed for publishing the new app. I would love to hear any other ideas of
> where to look to resolve getting styling applied and the Flask links working
> to access this app by URL instead of port.
>
>
>
> Thanks, Neil
>
>
> --
> 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 post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.