NGINX reverse proxy different backends

Discussion in 'Nginx' started by Domino1707, Feb 2, 2019.

  1. #1
    Hey there,

    I am just new to NGINX.

    I set up NGINX as a reverse proxy from subdomain.example.com which affects the internal ip 192.168.xxx.x . This works great.

    For now I want to reach another server in my network, let it call 192.168.xxx.Y .

    The Y should be available under subdomain.example.com/Y .

    How do I have to configure NGINX?

    This is my first try - which does not work:

    server {
    listen 80;
    server_name subdomain.example.com;

    location / {
    proxy_pass htp://192.xxx.xxx.x:80;
    }

    location /Y {
    proxy_pass htp://192.xxx.xxx.Y:377;
    }

    }

    Any suggestions what I am doing wrong?

    Cheers Domini
     
    Domino1707, Feb 2, 2019 IP
  2. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #2
    Your configuration should work, just add a forward slash after Y `location /Y/`. Nginx will select the location with the longest matching prefix.
     
    RoseHosting, Feb 16, 2019 IP