Serving static files with NGINX

Sdílet
Vložit
  • čas přidán 12. 09. 2024
  • Learn how to serve static files with NGINX, while delegating API calls to Node.js
    ------------------
    Deploying Node playlist:
    • Deploying Node
    IMPORTANT
    ------------------
    From 2018 and on, the setup in this video will only work if your SELinux is configured correctly (to allow nginx to connect to Node and to read files from home folder). Otherwise you will be getting "Not Found" and "Permission Denied" errors.
    Check out this video if that's what you are experiencing:
    • Understanding and Conf...

Komentáře • 34

  • @JuriyBura
    @JuriyBura  Před 6 lety +2

    IMPORTANT
    ------------------
    From 2018 and on, the setup in this video will only work if your SELinux is configured correctly (to allow nginx to connect to Node and to read files from home folder). Otherwise you will be getting "Not Found" and "Permission Denied" errors.
    Check out this video if that's what you are experiencing:
    czcams.com/video/HhydNtaLEK0/video.html

  • @umeshdhaked7638
    @umeshdhaked7638 Před 5 lety +2

    this type of how to videos are now my new fantasies . :)

  • @airxperimentboom
    @airxperimentboom Před 4 lety +2

    YOU SAVED MY ASS BUDDY. It's been 3 days I was unable to run my nginx server on docker because of right management that's sick !

    • @JuriyBura
      @JuriyBura  Před 4 lety

      Eelke Johnson glad it helped! :)

  • @jayaganthan1
    @jayaganthan1 Před 5 lety +4

    Can't thank you enough man. Great Video!

  • @kencharles7048
    @kencharles7048 Před 7 lety +3

    Exactly what I was looking for, and worked perfectly. Thanks!

    • @chill-hot-stream
      @chill-hot-stream Před rokem

      Hey there it also helped me deploy my Django application

  • @1011ph
    @1011ph Před 6 lety

    This is really really good. Thanks very much!! I encountered the permission issue and tried nginx_conf/user/group/selinux/ all not working finally with your "namei" command found one folder did not give 'x' permission. It works now. :)

  • @khalidelgazzar
    @khalidelgazzar Před rokem

    Great video. You're showing great details in both nginx & node.js .. thabk you!

  • @rhuzaifa
    @rhuzaifa Před 2 lety

    This saved me a ton of time. Thanks

  • @chill-hot-stream
    @chill-hot-stream Před rokem

    Thanks Jury you saved me today thanks I like your videos

  • @forbitbd3348
    @forbitbd3348 Před 4 lety +5

    chown: invalid group: ‘sohel:nginx’ . Here sohel is my user

  • @lucaoliveira100
    @lucaoliveira100 Před 4 lety +1

    Great video, can you help me with some tip? i have multiples locations where each on have a nodejs application, so i need setup multiples statics path

  • @glkoop
    @glkoop Před 9 měsíci

    I have a noob quetion, so in the case
    here
    our nginx would be storing the files ?
    if I am dockerized and my Nginx is a seperate docker/phisical-server then files host on that server ?

  • @alinajafi8824
    @alinajafi8824 Před rokem

    That’s great work me.

  • @FirstLast-hm8oz
    @FirstLast-hm8oz Před 3 lety

    Sorry, I cannot reach the static page even if I start an independant server listening on 8080. The error is always 404.

  • @saltzliu
    @saltzliu Před 6 lety

    Very good tutorial

  • @anandsingh1011
    @anandsingh1011 Před 5 lety

    Thanks you very much this ..

  • @joakimjohansson7729
    @joakimjohansson7729 Před 6 lety

    Love it! :D

  • @diegor5805
    @diegor5805 Před 4 lety

    What is the benefit of serving static files using nginx? What if I wanted to serve the home route using express, but still serve other static files using nginx?

  • @ПетроКобзар

    Я так понимаю нужно все запросы в node делать /api/some_req
    Тоесть я не могу тепер делать /some_req. Иначе он попадет к nginx. А тот его не обработает?

  • @JohnSmith-ud9fi
    @JohnSmith-ud9fi Před 6 lety

    I had one problem while following your tutorial. The thing is that you must also do: "chmod -R g+x /path/to/public/folder" and/or "chmod -R u+x /path/to/public/folder" to enable executing of this files. Because if your user (which is defined in nginx "user" directory nginx.org/en/docs/ngx_core_module.html#user ) won't have the rights to execute the files in your public folder it won't work.

    • @JuriyBura
      @JuriyBura  Před 6 lety

      Why would you want to "execute" files in the public folder? You have only to be able to "read" them. X is required to "cd" into the folder, which we did for user's home directory.

  • @trueduePL
    @trueduePL Před 6 lety

    in my fedora it doesn't work. When I set correct permissions I was still getting NOT PERMITED. I had to also disabled my SELinux in
    nano /etc/selinux/config
    SELINUX=disabled
    and now works good. thanks for video :)

    • @TekSchool
      @TekSchool Před 6 lety

      I run into the same issue. Disabling SELinux worked, but it didn't feel right. Why did we have to go through configuring SELinux in the first place?
      The answer was that I needed to set:
      chcon -Rt httpd_sys_content_t /home/USERNAME/easyio/public
      as indicated in the video about Understanding and Configuring SELinux.

  • @smartliga8623
    @smartliga8623 Před 6 lety

    Juriy need your help. How to serve dynamic index.html on rout "/" if nginx grabs this and try to give static file first.

    • @smartliga8623
      @smartliga8623 Před 6 lety

      How to serve dynamic index with static css in public folder. Index.html is not in public folder its dynamic. That's the question.

    • @JuriyBura
      @JuriyBura  Před 6 lety

      I don't quite get your setup. So your index.html is not there, since it is served by node.js? And what's nginx then serving?

    • @smartliga8623
      @smartliga8623 Před 6 lety

      I working on a new project now and it seems it's working fine now. I believe it was my mistake. Thank You for such awesome content

  • @darwinmendez8206
    @darwinmendez8206 Před 5 lety

    why you put there api/test?,

    • @JuriyBura
      @JuriyBura  Před 5 lety +1

      To simulate some kind of API that is available under that route.

  • @postal774
    @postal774 Před 6 lety +3

    Русский)

  • @AlexeyZubkov
    @AlexeyZubkov Před 5 lety

    Сертификат обнови дядя