[Flask] flask url_for / nginx proxy_pass
Ulrich Berthold
ub at artfacts.net
Fri Jun 10 06:43:58 EDT 2016
hey pascal,
when using blueprints, you can pass the url prefix as an argument to
register_blueprint, like this:
app.register_blueprint(api, url_prefix='/api')
will make api aceesable under https://my.url/api and urls created with
url_for in that context will have the prefix.
there is a stackoverflow question, which i think handles your problem:
http://stackoverflow.com/questions/18967441/add-a-prefix-to-all-flask-routes
cheers,
ub
On Fri, Jun 10, 2016 at 11:52:57AM +0200, Pascal wrote:
> hello,
>
> my flask app (flaskbb <https://github.com/sh4nks/flaskbb>) is listening on
> 127.0.0.1:8765 and is ok when accessed directly with http://127.0.0.1:8765/.
>
> when accessed through nginx with http://mywebserver/flaskbb/, all links are
> broken because /flaskbb is missing in the url (eg. src="/css/..." and not
> src="/flaskbb/css/...").
>
> I currently bypasses the problem by modifying the templates, but it's not
> clean :-(
>
> how can I solve this problem ?
>
> note that nginx directive is location /flaskbb/ { proxy_pass
> http://127.0.0.1:8765/; } and I can't play with virtual-server/dns.
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/flask/attachments/20160610/872f52d3/attachment.sig>
More information about the Flask
mailing list