Deploy Flask Application on Ubuntu VPS using Nginx

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ธ.ค. 2024

ความคิดเห็น • 99

  • @mustafahajhamoud2077
    @mustafahajhamoud2077 8 หลายเดือนก่อน +4

    thank you very much! I've been trying to do this for 3 days now, and your tutorial is the only one that worked for me.

  • @vat1980
    @vat1980 2 ปีที่แล้ว +9

    Really want to say thank you so much. Many tutorials end up in error but this one is spot on! Got my Flask app running on AWS ES2 in less than 15 mins. Great video.

  • @cfuendev
    @cfuendev ปีที่แล้ว +3

    The constant "..Need to sudo before this" is very relatable

  • @nicholashooper9538
    @nicholashooper9538 2 ปีที่แล้ว +6

    Been banging my head against the wall from lots of other tutorials, this was the only one to work for me all the way through, and I have quite a large/complex Flask App. Thank you so much

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว +3

      Lmao Head banging ain't that uncommon, especially for developers
      Thanks a lot :)

  • @trueindian03
    @trueindian03 2 หลายเดือนก่อน

    Thankyou so much for the video, I literally referred many youtube videos and articles none of them help me much, but your tutorial help me.

  • @perilous105
    @perilous105 3 ปีที่แล้ว +12

    I don't really comment on many videos, but this was a brilliant tutorial. I've been looking at so many tutorials, but there was always an error with them, if it wasn't nginx it was apache2. Thank you for the quick and clear explanation. Keep doing videos like these!

    • @devguyahnaf
      @devguyahnaf  3 ปีที่แล้ว +3

      Thanks a lot for your kind words. I really appreciate them :)
      Also, one thing I would like you to know is that Apache is a threaded server, which means it is prone to DDOS and DOS attacks. But Nginx on the other hand is an asynchronous web server and reverse proxy, so it is not as vulnerable as Apache, and it is also very easy to set up.

    • @perilous105
      @perilous105 3 ปีที่แล้ว

      @@devguyahnaf That's great to know, glad I made the right choice!

    • @kushagramishra4795
      @kushagramishra4795 3 ปีที่แล้ว

      I'll plus one this , great video !!!

  • @notlilmond
    @notlilmond 5 หลายเดือนก่อน

    Very underrated channel. I've searched many tutorials and ended up to this channel multiple times. I hope you keep going with making tutorials bro, great things are waiting for you out there! And you really help a lot of people with your work. Much appreciated! ♥💯

  • @B20DCCN148-DoBaDuy
    @B20DCCN148-DoBaDuy 11 วันที่ผ่านมา

    Thank you very much! A small note, you can still use gunicorn instead of gunicorn 3, and if your RAM is weak, set workers = 1

  • @samiam.402
    @samiam.402 2 ปีที่แล้ว

    Brooooooo!!! This is the only tutorial I could find to show how to keep the gunicorn or flask app alive after exiting the ssh connection!!!! Thanks a bunch.

  • @FelipeCatao
    @FelipeCatao 2 ปีที่แล้ว

    friend without words, you helped me to climb my flask application that was 3 weeks trying without success, congratulations by the tutorial clear and direct

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      You're welcome, glad to hear that!

  • @ronmercier9841
    @ronmercier9841 ปีที่แล้ว

    Thank you for this tutorial, it was super helpful. I was able to get my fullstack app running on my Linode server with no issue. Much appreciated and keep up the good work!

  • @MadZorf
    @MadZorf ปีที่แล้ว

    Man, as others have also mentioned. Your tutorial saved my project! Thank you so much!!!

  • @kawsarlog
    @kawsarlog ปีที่แล้ว

    My friend you just did an outstanding job, not only the tutorial you also explained a lot of basic stuff!

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว +1

      Thank you, glad it was helpful

  • @walkerlasbury9315
    @walkerlasbury9315 2 ปีที่แล้ว +1

    So helpfull! Best video out there!

  • @phi6934
    @phi6934 ปีที่แล้ว +1

    What an amazing tutorial, I learned a ton of useful stuff, thanks!

  • @AdhithyaRamesh-os2gy
    @AdhithyaRamesh-os2gy ปีที่แล้ว +1

    This was awesomee, i have a big flask app with D.L models and every other tutorial used github which doesn't allow files bigger than 25MB. This was seriously f*ckin awesome.

  • @marconeramos1194
    @marconeramos1194 ปีที่แล้ว

    Thank you! This tutorial is simply the best I found! Saved my week!

  • @dev_ritchie
    @dev_ritchie 6 หลายเดือนก่อน

    Excactly what i was searching for 🎉🎉

  • @olumorsotnas
    @olumorsotnas ปีที่แล้ว

    Very good explanation my friend. This video saved me :)

  • @EnglishRain
    @EnglishRain 2 ปีที่แล้ว

    Wow 13:45 is a GREAT tip, thank you so much!

  • @ryu8777
    @ryu8777 2 ปีที่แล้ว +1

    Best of the best! Btw for me gunicorn3 can't be imstalled, but gunicorn works just great (ubuntu 20.04). Many many thanks DevGuyAhnaf!

  • @niksushko9333
    @niksushko9333 ปีที่แล้ว

    Thx bro, very useful for me!

  • @MyStockz
    @MyStockz 2 ปีที่แล้ว

    What a legend! Super clear! No bulls*it in between.

  • @marknelsonmamerto1381
    @marknelsonmamerto1381 หลายเดือนก่อน

    What do I need if I'm deploying api through the IP only? Because its blocking the requests for the api access

  • @ero-sennin6623
    @ero-sennin6623 2 ปีที่แล้ว

    thank you bro, u deserve more subscribers.

  • @leomeror
    @leomeror 2 ปีที่แล้ว

    This is very helpful! Well made! :)

  • @AntonioGargiulodragossido
    @AntonioGargiulodragossido ปีที่แล้ว

    This is the only guide that has made me run Python on server so far.
    for some reason before running Gunicorn I need to reboot the server.
    if i want to add a second app?

  • @gusinthecloud
    @gusinthecloud ปีที่แล้ว

    You made the best video!!! Thank you

  • @castleold19
    @castleold19 ปีที่แล้ว

    I can't save reverse proxy, it's showing file or directory doesn't exist.

  • @dreumairali
    @dreumairali 7 หลายเดือนก่อน

    i done everythin and unicorn3 is also running on port 8000 but when i go to my main ip it is showing me nginx

  • @odepleted
    @odepleted ปีที่แล้ว

    how do you get dark theme in filezilla?

  • @guipe7712
    @guipe7712 2 ปีที่แล้ว

    Thanks Friend, excellent video. I learn a lot. Works perfectly in hostinger vps. Thanks a lot

  • @Notus29
    @Notus29 ปีที่แล้ว

    what if your using a docker container

  • @alaminbijoy1027
    @alaminbijoy1027 3 ปีที่แล้ว

    Great concise tutorial bro
    Take love

  • @jakubkrajewski8249
    @jakubkrajewski8249 2 ปีที่แล้ว

    how to add multiple urls?

  • @samjiman
    @samjiman 9 หลายเดือนก่อน

    Good video, thank you.

  • @julian3154
    @julian3154 ปีที่แล้ว

    Great video, thank you!

  • @96NewsHDofficial
    @96NewsHDofficial ปีที่แล้ว

    broo what if i do 443 beside 80 for ssl will it work?

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว +1

      Only if you have proper SSL certification/configuration available for NGINX.

  • @Yathavpriyan
    @Yathavpriyan 2 ปีที่แล้ว

    great one. worked well. thanks !

  • @user-yn2me7in5n
    @user-yn2me7in5n 3 ปีที่แล้ว

    Awesome tutorial, thanks!

  • @moshiurrahman1454
    @moshiurrahman1454 2 ปีที่แล้ว

    Really greate video

  • @karthik-pillai
    @karthik-pillai 2 ปีที่แล้ว

    BEST VIDEO!

  • @nicoxvxv
    @nicoxvxv 2 ปีที่แล้ว

    So i followed the tutorial, but i have a little problem. After running "gunicorn --workers=3 app:app" the main ip of my server is showing "Bad Gateway" and i dont know what i did wrong.

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      The reverse proxy (Nginx in this case) is probably trying to find the gunicorn server on a specified port, but the server is not on that port. By default, the gunicorn server listens on port 8000, so your Nginx proxy would have to forward the requests to 127.0.0.1:8000. You would have the config sorta like this:
      location / {
      proxy_pass 127.0.0.1:8000;
      }
      This will load balance all the requests sent to your nginx server (through the main IP) and forward it to the gunicorn server so that people can access your flask application

    • @nicoxvxv
      @nicoxvxv 2 ปีที่แล้ว

      @@devguyahnaf fixed.

  • @mohamed-hm8pn
    @mohamed-hm8pn 2 ปีที่แล้ว

    thank you so much ....amazing work best video on youtube for this tut

    • @mohamed-hm8pn
      @mohamed-hm8pn 2 ปีที่แล้ว

      it wotk perfect on google cloud platform too

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      @@mohamed-hm8pn Yes, it was intended for every VPS running Ubuntu

  • @vinter_man
    @vinter_man 2 ปีที่แล้ว

    totally helpful, thx!!!

  • @lambuth
    @lambuth ปีที่แล้ว

    Thank you for this. So much.

  • @AdrienZier
    @AdrienZier 2 ปีที่แล้ว

    Great tutorial! Just wondering what's the use of the 2 lines under proxy_pass? the header forwarding. what does that achieve? many thanks!!

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว +2

      Sorry for the late reply. All it does is provide the Flask app with some headers that contain the actual client information. This might be important for IP logging, or other analytical stuff in your application, since Flask doesn't directly get the client's info as it gets proxied by Nginx

  • @timberlee9176
    @timberlee9176 3 ปีที่แล้ว

    Many thanks for you bro; it's very helpful.

  • @syedmujahid9860
    @syedmujahid9860 9 หลายเดือนก่อน

    is steps same for deployment in aws ,hope for quick reply

    • @devguyahnaf
      @devguyahnaf  9 หลายเดือนก่อน +1

      On an AWS EC2, should be same. Just configure elastic IP and proper ports

  • @ironF5
    @ironF5 2 ปีที่แล้ว

    it shows E: Package 'gunicorn3' has no installation candidate

    • @ryu8777
      @ryu8777 2 ปีที่แล้ว

      same for me, I just installed gunicorn and it works

  • @xplt3
    @xplt3 ปีที่แล้ว

    PERFECT, Thanks!

  • @dw4258
    @dw4258 ปีที่แล้ว

    Thanks, got my app working! It's on port 8050 though which is strange... (Added later) the call to gunicorn was app:server and not app:app

  • @prasadnijai2820
    @prasadnijai2820 2 ปีที่แล้ว

    I'm using vultr to host my website. And everything till last worked fine.. but gunicorn --workers=3 app:app is not working for me. It is not fetching site even by local host

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      Why are you using localhost though? Use the VPS's IP
      Also, make sure the host is 0.0.0.0
      Bind gunicorn to 0.0.0.0 as well

    • @prasadnijai2820
      @prasadnijai2820 2 ปีที่แล้ว

      @@devguyahnaf So What changes i have to do in sites-enabled/flask_app ? Do I have to replace proxy_pass IP ?

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      ​@@prasadnijai2820 Nope. Try adding a bind argument to gunicorn
      "--bind=0.0.0.0"

  • @coldluck7366
    @coldluck7366 7 หลายเดือนก่อน

    legend

  • @divyar5238
    @divyar5238 3 ปีที่แล้ว

    Thanks, I get a "502 Bad Gateway
    nginx/1.18.0 (Ubuntu)" error. Do you know why ?

    • @devguyahnaf
      @devguyahnaf  3 ปีที่แล้ว

      Nginx is trying to proxy the request to the flask server. Are you sure that the flask app is running?

    • @divyar5238
      @divyar5238 3 ปีที่แล้ว

      Yes, flask app runs fine in local host

    • @devguyahnaf
      @devguyahnaf  3 ปีที่แล้ว

      @@divyar5238 You need to keep it running in the background, so that Nginx can reverse proxy it.

    • @billycherry7028
      @billycherry7028 3 ปีที่แล้ว

      @@devguyahnaf Hey, I'm having the same problem. I get that same error even when the app is running

  • @emotional_stuff
    @emotional_stuff ปีที่แล้ว

    nice one

  • @eliasoliveira292
    @eliasoliveira292 2 ปีที่แล้ว

    Thanks man!!!

  • @biskweet816
    @biskweet816 2 ปีที่แล้ว

    Excellent video. I would love to see a tutorial on how to setup TLS/SSL with this config.

  • @ironF5
    @ironF5 2 ปีที่แล้ว

    now tell us how to dockerize this? as ECR and lightsail has containers... that runs dockerized images only

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      This tutorial was specifically for VPS services such as AWS EC2, DO Droplets, GCP VMs, etc.
      But for container runtimes such as AWS ECR, you can take a look at this video: th-cam.com/video/grtjkDh5DmQ/w-d-xo.html
      Just skip the react part and only watch Flask

    • @ironF5
      @ironF5 2 ปีที่แล้ว

      @@devguyahnaf can u show how to deploy a dockerized flask app on AWS sagemaker and lightsail container that can handle 5-10 requests at once meaning use of load balancer of some sort ( i have actually completed the lightsail deployment step) ... can u also tell the difference between 3 workers of gunicorn and loadbalancer use in deployed app..

  • @qrythe
    @qrythe 3 ปีที่แล้ว

    U helped me so much

  • @AabhusanAryalOfficial
    @AabhusanAryalOfficial 2 ปีที่แล้ว

    Thanks a lot!

  • @PPRASHAR25
    @PPRASHAR25 2 ปีที่แล้ว

    helped me at last moment..

  • @ha2709
    @ha2709 ปีที่แล้ว

    Thank you

  • @KingMarques
    @KingMarques 2 ปีที่แล้ว

    Hey DevGuy, how are you?
    '
    Dev, i'm trying to deploy a flask api on a Ubuntu Serve, but this api must bem deployed not in a Cloud, but inside of my company Server. I can do this task with this tutorial?
    We are using ubuntu 22.04 Server, Anaconda Python 3.9.
    Thank you very much!

    • @KingMarques
      @KingMarques 2 ปีที่แล้ว

      Hey Dev, i'm here again, but now it is another question about "gunicorn3 --workers=3 file:app". In my situation, a have a function Main and my app flask is inside this Function Main, and when i try to call the App with gunicorn, the server return for me saying I'm trying to pass two parameters when Main requires 0. How can I refer this app flask inside the Main who is inside the file?

  • @inferlight
    @inferlight 3 ปีที่แล้ว

    Sheeeeesh

  • @andreaskweyo5582
    @andreaskweyo5582 2 ปีที่แล้ว

    Wow, say no more

  • @DT-hb3zu
    @DT-hb3zu 2 ปีที่แล้ว

    Are we just gonna ignore that his filezilla is dark mode?

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      Yes.
      :)

    • @DT-hb3zu
      @DT-hb3zu 2 ปีที่แล้ว

      @@devguyahnaf I love the tutorial my guy, got set up and running from it.
      Now, let's get back to dark mode FZ
      😂🤣
      (Possible new tutorial?)
      **FZ has dark mode?**

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      @@DT-hb3zu You see, I had dark mode enabled on my desktop environment (Cinnamon) back when I used Linux Mint. So Filezilla for Linux basically uses the QT/GTK theme that's set by the DE, and that's how I got dark mode

    • @DT-hb3zu
      @DT-hb3zu 2 ปีที่แล้ว

      @@devguyahnaf gaaahh. I figured. I can get it on my Debian, but not my windows. And all "dark mode" on desktop look like poo. Thank you! You have very nice content. Straight to the point, and (maybe not intentional) show some common mistakes. Brilliant

  • @karasiq69
    @karasiq69 ปีที่แล้ว

    That helps a lot, thank you

  • @jerrywang3225
    @jerrywang3225 ปีที่แล้ว

    This is really helpful. Thanks

  • @codepunk77
    @codepunk77 10 หลายเดือนก่อน

    thanks a lot