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
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 ?
Thanks ma man! This really helped, other guides add a lot of information that it becomes overwhelming
Great video, thanks for sharing 👍. I am much more familiar with Apache so it was neat to see the equivalent on Nginx.
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
wow I went many years never knowing that sudo stands for Super User DO. Thanks for the tutorial!
Nah bruh it means Shut Up and Do as Ordered
You saved my so much time. Thank you sooo much
Thank you so much! so much appericate you made this simple.....
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?
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 :)
@@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
@@petertremblay3725 yup two sites cannot run on the same port of the same computer
@@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?
Thanks. Love this one.
Thanks man! Your video was very informative.
Thank you very much for the clear explanation
Thanks Man you solve my problem
There are some things which are not really clear else there is so much to learn from this video
hi friend thanks for sharing! where did you store the index files of the site to bee on port 8081?
Thank you! 😄
thanks man!
Thank you for posting such great content. However, can we do the same thing by using IIS ?
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
Could you please provide an example ?
You sound really similar to gotbletu! Thanks for the tutorial bro
Can I reverse proxy any website on my domain?
do we need install bind9 to do this? (i know it's a noob question sorry about that :)
Hello Im wondering how to host as https with nginx do you know how?
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
You need to setup SSL for port 443
@@JuanNadal yes i did using cerbot... my question is why some functionality work in 80 not in 443
I am trying to link multiole mqtt websockets on various domains... like e1.domain.com->mqtt1
e2.domain.com->mqtt2...etc
Please acknowledge me
do you have the same for windows 10?
also, does it block access to: IP:PORT ? e.g someone manually go to 157.230.151.33:8080
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.
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?
502 Bad Gateway How do I fix that?
default server is working but another one is not working.
Can anyone help me?
Can you provide ssl certificate to both the sites from your Nginx?
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.
How about if you have Cloudflare in between?
Cloudflare doesn't care, works fine with it.
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