Nginx Reverse Proxy Set Up ( Multiple Server On The Same Port One IP )

Nginx Reverse Proxy Set Up ( Multiple Server On The Same Port One IP )


shared hosting reverse proxy

How to setup a reverse proxy with Nginx.

# CLI

sudo nano /etc/nginx/sites-available/default

“`

server {
listen 80;
server_name HOST_NAME_OF_YOUR_SIT;

location / {
proxy_pass
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

server {
listen 80;
server_name HOST_NAME_OF_YOUR_SITE;

location / {
proxy_pass
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

“`

sudo systemctl reload nginx

Please like and subscribe!

#TateA

23 thoughts on “Nginx Reverse Proxy Set Up ( Multiple Server On The Same Port One IP )

  1. Thanks its working !!!!!!!!!!!!!!!!!!!!!!!! I have used this proxy for Fusionauth application that is run 9011
    now it's working on only with localhost without entering port no
    again thank you

  2. Hi!
    Thank you very much for your help!
    I watched tons of videos and I did the same thing as what they did, but none of them was helpful. And now I found you, and you've helped me a lot, your video is much shorter than others but has more information and it's more understandable than other's one.

    Thank you so much again, hope you're doing great today! 🙂
    See you later!

  3. Great Video! I am fairly new to this, so will I have to change the port 80 on the web servers virtual host or can I just leave that? like for example in the header of the virtual host it has <VirtualHost *:80> would I have to change the 80? also I changed the web server to 80.80.80.80, 80.80.81.81 that is manual, do I change this to automatic if I use a reverse proxy? sorry for so many questions, but for the reverse proxy server, in the router settings, do I have that server ip port forwarded to port 80? last question as of now (sorry again if I have more in the future) if I already have a website that hs an ssl certificate from cloudflare and I do the reverse proxy that you showed here, would it affect it at all because what you showed was only http and not https? Thanks! if you need me to clarify more, I will try my hardest to explain what I am asking. Thanks Again.

  4. I don't have domains to my remote servers. I'm tyring to do reverse proxy using IP address. So the url will http://nginxip:80/ this will hit my first remote server and give me response and http://nginxip:80/serv2 this will hit my second remote server and give me the response. The challenge here is the first one is working fine but when second isn'yt working as expected it is giving 404 while serving static files

    server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _localhost;

    location / {

    proxy_pass http://10.1.2.9:8000/;
    }
    location /test/ {

    proxy_pass http://xxxxxxx:8000/;
    }
    }

Leave a Reply

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