[Flask] URL rewriting (url_for) issues with Flask 0.11.1 and fastcgi
Erik Lindqvist
eriksmejl at gmail.com
Mon Oct 17 13:42:58 EDT 2016
Hi,
So I found a workaround, credit to http://stackoverflow.com/a/38662338
TL;DR SCRIPT_NAME has to be set to "" in the environment before passing the
app to WSGI.
So the issue seems to be that "SCRIPT_NAME" in the environment is wrong
somehow.
Does annyone know where I should find an issue?
mod_fastcgi?
Werkzeug?
Flup?
Flask?
Also, I had to change the alias.url path to make sure the local path has a
trailing "/". Static files can't be accessed otherwise, will submit a PR
for the documentation.
//Erik
On Thu, Oct 13, 2016 at 3:28 PM, Erik Lindqvist <eriksmejl at gmail.com> wrote:
> Basically a copy of the fastcgi example from the docu, minus the port
> binding:
> $SERVER["socket"] == ":5000" {
> fastcgi.server = ("/yourapplication.fcgi" =>
> ((
> "socket" => "/tmp/tti-app-fcgi.sock",
> "bin-path" => "/local/www/wwwroot/yourapplication/
> yourapplication.fcgi",
> "check-local" => "disable",
> "max-procs" => 1
> ))
> )
> alias.url = (
> "/static/" => "/local/www/wwwroot/yourapplication/static"
> )
> url.rewrite-once = (
> "^(/static($|/.*))$" => "$1",
> "^(/.*)$" => "/yourapplication.fcgi"
> )
> }
>
>
> On Thu, Oct 13, 2016 at 1:52 PM, Sébastien Billion <
> sebastien.billion at gmail.com> wrote:
>
>> Can we see your lighthttpd conf file?
>>
>> 2016-10-13 11:21 GMT+02:00 <badrihippo at gmail.com>:
>>
>>> I have this same issue, with Flask 0.10.1, Werkzeug 0.11.3 and mod_wsgi.
>>> I haven't found any solution yet. But I'm guessing this means it's a
>>> generic problem (not related to version)?
>>>
>>>
>>> The main problem is that the server directs it to that .fcgi or .wsgi
>>> file internally, but we don't want it to show that to the user. Django
>>> allows you to manually set the URL prefix; maybe there's a way to do this
>>> in Flask as well?
>>>
>>> —Badri/Hippo
>>>
>>>
>>>
>>> _______________________________________________
>>> Flask mailing list
>>> Flask at python.org
>>> https://mail.python.org/mailman/listinfo/flask
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20161017/41fbbf3d/attachment.html>
More information about the Flask
mailing list