Run Multiple Site from one IP with reverse proxy Nginx

Поділитися
Вставка
  • Опубліковано 19 жов 2024
  • How to run multiple sites on one web-server using Nginx by creating a virtual host.
    Also shows how to host dynamic content using port 8080 and 8081
    Free Trial on Digital Ocean: m.do.co/c/8add...
    Helpful sites:
    www.digitaloce...
    nginx.org/en/do...
    ----------------------------------------------------------------------------------------------
    commands used during video:
    sudo apt install nginx
    ---show content in "site enable"
    unlink default
    -- create new conf file in conf.d
    newsite.conf
    --- past server block into .conf file
    server {
    listen 80 default_server;
    server_name yourdomain1.xyz www.yourdomain1.xyz;
    location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass localhost:8081;
    }
    }
    server {
    listen 80;
    server_name yourdomain2.info www.yourdomain2.info;
    location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass localhost:8080;
    }
    }
    nginx -t
    systemctl reload nginx
    systemctl status nginux

КОМЕНТАРІ • 50

  • @vishalparkar
    @vishalparkar 2 роки тому +3

    Thank you very much ! Subscribed and liked !!
    One query though. at 5:56 did you paste the server block for the second site just below the first or just replaced the first with the second ? If this is the second case, then how did both the urls work if the config for the first is replaced ?

  • @kahelsoro
    @kahelsoro 3 роки тому +1

    Thanks ma man! This really helped, other guides add a lot of information that it becomes overwhelming

  • @logicawe
    @logicawe 4 роки тому +4

    Great video, thanks for sharing 👍. I am much more familiar with Apache so it was neat to see the equivalent on Nginx.

  • @tanchienhao
    @tanchienhao 2 роки тому +1

    at 6:01 how come you replaced the balckjack website? and also im curious what happened to the at 2:07. thank you for the great video! :D

  • @tultr
    @tultr 3 роки тому

    wow I went many years never knowing that sudo stands for Super User DO. Thanks for the tutorial!

    • @rukasu01
      @rukasu01 2 роки тому +1

      Nah bruh it means Shut Up and Do as Ordered

  • @RahulYadavhacker
    @RahulYadavhacker 3 роки тому

    You saved my so much time. Thank you sooo much

  • @RichardApplegate
    @RichardApplegate 5 років тому +2

    Thank you so much! so much appericate you made this simple.....

  • @PeterBatah
    @PeterBatah 2 роки тому +1

    Thanks for sharing you time and experience with us. Quick question. Where does the content for the two sites reside? And would it require a folder for each of your sites?

    • @tanchienhao
      @tanchienhao 2 роки тому +2

      they can reside anywhere they want as long as they are accessible on the ports. nginx simply redirects requests to the relevant ports. you can have a folder for each site for better organisation. hope this helps :)

    • @petertremblay3725
      @petertremblay3725 2 роки тому

      @@tanchienhao I am confuse about the port change, i got 3 websites that i want to have on my vps and served by nginx so do i have to open new ports for each additional website? Thank for any help

    • @tanchienhao
      @tanchienhao 2 роки тому +1

      @@petertremblay3725 yup two sites cannot run on the same port of the same computer

    • @petertremblay3725
      @petertremblay3725 2 роки тому

      @@tanchienhao Thank i was confuse about that part since so many channel do thing differently! But if i set nginx as reverse proxy then more than 2 sites can be on same port correct?

  • @masudrana1983
    @masudrana1983 3 роки тому

    Thanks. Love this one.

  • @dipanshuc
    @dipanshuc 4 роки тому

    Thanks man! Your video was very informative.

  • @diosmio2009
    @diosmio2009 4 роки тому

    Thank you very much for the clear explanation

  • @MuhammadAmir-ff8wl
    @MuhammadAmir-ff8wl 3 роки тому

    Thanks Man you solve my problem

  • @tarvinder91
    @tarvinder91 3 роки тому

    There are some things which are not really clear else there is so much to learn from this video

  • @angelthekind1595
    @angelthekind1595 4 роки тому +3

    hi friend thanks for sharing! where did you store the index files of the site to bee on port 8081?

  • @colorghost
    @colorghost 2 роки тому

    Thank you! 😄

  • @blackestwhite
    @blackestwhite 5 років тому +3

    thanks man!

  • @ahsanraza4762
    @ahsanraza4762 4 роки тому

    Thank you for posting such great content. However, can we do the same thing by using IIS ?

  • @georgesmith3022
    @georgesmith3022 3 роки тому

    this is how to proxy to different sites based on server name. This means you should run now nginx plus two more servers. If you want to run multiple servers on the same server you just need a different root folder and remove the proxy commands

  • @yugiohsc
    @yugiohsc 4 роки тому

    You sound really similar to gotbletu! Thanks for the tutorial bro

  • @techsapphire
    @techsapphire 4 роки тому

    Can I reverse proxy any website on my domain?

  • @ariloguecom
    @ariloguecom 3 роки тому

    do we need install bind9 to do this? (i know it's a noob question sorry about that :)

  • @Scuffy
    @Scuffy 3 роки тому

    Hello Im wondering how to host as https with nginx do you know how?

  • @azartheen428
    @azartheen428 3 роки тому

    hi...
    i need help from you iam working on java JSP page on the tomcat server i can access all post and get method in 80 port but not working in 443 what happens.. and what is the problem can you please explain me or fix this problem

    • @JuanNadal
      @JuanNadal  3 роки тому

      You need to setup SSL for port 443

    • @azartheen428
      @azartheen428 3 роки тому

      @@JuanNadal yes i did using cerbot... my question is why some functionality work in 80 not in 443

  • @okenkhuman_logicbee
    @okenkhuman_logicbee 4 роки тому

    I am trying to link multiole mqtt websockets on various domains... like e1.domain.com->mqtt1
    e2.domain.com->mqtt2...etc
    Please acknowledge me

  • @lotusmojo
    @lotusmojo 3 роки тому

    do you have the same for windows 10?

  • @brunobernard86
    @brunobernard86 5 років тому +1

    also, does it block access to: IP:PORT ? e.g someone manually go to 157.230.151.33:8080

    • @vedprakash-zz6hb
      @vedprakash-zz6hb 4 роки тому

      Yes
      Use empty host and return 444 e.g
      server { listen 80; server_name ""; return 444; }
      Here, the server name is set to an empty string that will match requests without the “Host” header field, and a special nginx’s non-standard code 444 is returned that closes the connection.

  • @luit.s
    @luit.s 3 роки тому

    I have a TL-WDR4300 router with openwrt nginx-ssl, acme and duckdns. I am struggling to install a reverse proxy any one have ever try anything like this?

  • @JamesKaneF
    @JamesKaneF 3 роки тому

    502 Bad Gateway How do I fix that?

  • @srijansingh8272
    @srijansingh8272 4 роки тому

    default server is working but another one is not working.
    Can anyone help me?

  • @LOVEUNEO
    @LOVEUNEO 4 роки тому

    Can you provide ssl certificate to both the sites from your Nginx?

    • @svampebob007
      @svampebob007 3 роки тому

      yes, you just need to sign the ssl certificate with the correct domain name and add it to the config file, or you could use a CA that way you only need to singe a single certificate.

  • @StefTechSurfer
    @StefTechSurfer 4 роки тому

    How about if you have Cloudflare in between?

    • @weiiswurst
      @weiiswurst 4 роки тому

      Cloudflare doesn't care, works fine with it.

  • @nikhilsinha2191
    @nikhilsinha2191 2 роки тому +1

    to achive the think which he did earlier edit the listen to 8080 or 8081 in the /etc/nginx/sites-available/{yourfilename} to get the desired results as him