[Flask] Deploying Flask on Debian

Anthony Ford ford.anthonyj at gmail.com
Thu May 5 16:21:10 EDT 2016


In your nginx conf for the specific app (the "server" section,
https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a#file-foobarapp-conf-L1
for example), you set the servername that you want to serve a specific site
under (see
https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a#file-foobarapp-conf-L3).
This is taken from the HTTP Host field. If you specify something on this
line, the server won't respond properly if you access via some other host.

For example,  if you set servername to myserver.example.com, and go to the
server's IP (i.e. 10.10.10.10/myapp/somepage), it won't respond, because
Nginx doesn't know to dispatch the request to your app. If you put
10.10.10.10 in your hostfile as myserver.example.com, and go to
myserver.example.com, it will work, as the Host field is now properly set.

If you have an internal DNS resolver, you can add an alias or mapping for
your server with the desired subdomain (this is what we did). If you are
testing, and don't want to/can't set up a DNS or host record in your host
file, or if you only have a single app, you can set the servername to *.
This will cause Nginx to dispatch _ALL_ requests to your app.


Anthony Ford,
KF5IBN,
ford.anthonyj at gmail.com

On Thu, May 5, 2016 at 1:54 PM, Alex Hall <ahall at autodist.com> wrote:

> Okay, thanks. Changing venv to match chdir seems to have worked. I still
> can't see my app, but at least UWSGI starts with no errors. Now to figure
> out how to let Nginx serve the pages to other computers on the intranet;
> this site is supposed to be a subdomain to a larger site, so I just want to
> map its IP to a subdomain on our internal DNS. Yet, [server_ip]/mySiteName
> returns a 404. Should be fun to troubleshoot. :)
>
> On Thu, May 5, 2016 at 2:41 PM, Corey Boyle <coreybrett at gmail.com> wrote:
>
>> That's where you specify the location of your virtualenv.
>>
>> On Thu, May 5, 2016 at 2:36 PM, Alex Hall <ahall at autodist.com> wrote:
>> > Sorry for all the messages, but one more thing about UWSGI. There's one
>> item
>> > in the configuration file sample I found that I don't understand:
>> >
>> > venv = /var/www/mysite/.env
>> >
>> > I can't find this venv item anywhere so far, and the author of the post
>> > where I found it never explained what it was for. Does it point to a
>> special
>> > folder used during runtime? Does that folder have to exist first? Does
>> this
>> > point to my app's folder, like chdir does? I don't have a .env folder,
>> and
>> > I'm wondering if that's my problem. I don't want to make one, though,
>> until
>> > I better understand what this venv item is actually trying to do.
>> >
>> > On Thu, May 5, 2016 at 2:24 PM, Edward Wingate <edwingate8 at gmail.com>
>> wrote:
>> >>
>> >> > At the risk of going a bit off topic, I made my Nginx and UWSGI
>> >> > configuration files according to this guide:
>> >> > http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/
>> >>
>> >> Here is another guide based on supervisor instead of systemd startup I
>> >> followed a while back:
>> >>
>> >>
>> http://ewong.me/creating-and-deploying-flask-app-using-uwsgi-nginx-virtualenv-and-supervisor/
>> >>
>> >> Maybe you can use bits of it to get your setup working.
>> >
>> >
>> >
>> >
>> > --
>> > Alex Hall
>> > Automatic Distributors, IT department
>> > ahall at autodist.com
>> >
>> > _______________________________________________
>> > Flask mailing list
>> > Flask at python.org
>> > https://mail.python.org/mailman/listinfo/flask
>> >
>>
>
>
>
> --
> Alex Hall
> Automatic Distributors, IT department
> ahall at autodist.com
>
> _______________________________________________
> 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/20160505/dd7a0e39/attachment-0001.html>


More information about the Flask mailing list