Run Multiple Site from one IP with  reverse proxy Nginx

Run Multiple Site from one IP with reverse proxy Nginx



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:

Helpful sites:

———————————————————————————————-
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
}

}

server {
listen 80;
server_name yourdomain2.info www.yourdomain2.info;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass
}
}

nginx -t

systemctl reload nginx

systemctl status nginux

22 thoughts on “Run Multiple Site from one IP with reverse proxy Nginx

  1. 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

  2. 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

  3. Is there a way for my domain path to point to another domain? For example, I want my site: http://www.mysite.com/SOME_DIRECTORY_POINTS that will point to a different domain when a user loads up "http://www.mysite.com/SOME_DIRECTORY_POINTS" and the user is NOT redirected, they still see that url, but just a different domain is presented?

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

  5. Hi did you type the two block server in the same file new_sites.conf or they are separated ? Gracias Juan (Spanish Name)

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

  7. so each website you host on the machine will "own" a different port right?
    in your example blackjack.xyz had port 80
    and loadpayment.info had 8080
    if i was to add another website i would have had to choose another port ?
    like example.info:42222

  8. So you can't just add the two sites to the "default" file? What is the contents of "new_sites.conf"? You edited your video and didn't make it clear.

  9. Question , ive got my IP address , got 2 apps running 1 on 5000 and one on 5100 , i want to be ip/Api redirect to 5000 and ip/Api2 to redirect to 5100 , how do i config that?

Leave a Reply

Your email address will not be published. Required fields are marked *