OPNsense Forum

English Forums => Web Proxy Filtering and Caching => Topic started by: travelback on December 23, 2018, 01:25:57 am

Title: Nginx as reverse proxy
Post by: travelback on December 23, 2018, 01:25:57 am
Hi, I'm setting up Nginx as a reverse proxy in 18.7.9 and can't get the setup to work. I have three servers setup, but only one works as expected. I'm not load balancing.

Here is a list of my settings:

Location (points to upstream server)
Description     URL Pattern      Match Type
Server 1         /                      Case Insensitive
Server 2         /                      Case Insensitive
Server 3         /                      Case Insensitive


HTTP Server (points to location)
Description     Ports               Real IP Source               Server Name
Server 1         80/443            X-Forwarded-For            xxxx.xxx
Server 2         80/443            X-Forwarded-For            xxxx.xxx
Server 3         80/443            X-Forwarded-For            xxxx.xxx


Upsteam Server
Description     Server                   Port        Server Priority
Server 1         xxx.xxx.xxx.xxx     ####    1
Server 2         xxx.xxx.xxx.xxx     ####    1
Server 3         xxx.xxx.xxx.xxx     ####    1


Upstream (points to server entry)
Description     PROXY Protocol
Server 1         checked
Server 2         checked
Server 3         checked

What am I missing??
Title: Re: Nginx as reverse proxy
Post by: fabian on December 23, 2018, 08:41:14 am
You probably have set up a load balancer setup because if I understand that correctly, you have multiple servers in your upstream. All servers in your upstream must behave exactly the same way (and the servers must be able to serve all pages if needed if you group then in an upstream).
Title: Re: Nginx as reverse proxy
Post by: travelback on December 25, 2018, 05:46:18 am
You probably have set up a load balancer setup because if I understand that correctly, you have multiple servers in your upstream. All servers in your upstream must behave exactly the same way (and the servers must be able to serve all pages if needed if you group then in an upstream).

I do have multiple servers, but they serve separate content. How do I set this up and not load balance?

As an example setup

Server 1 needs access to port 80/443 for a wordpress site and port 8080 for an admin panel
Server 2 needs access to port 80/443 for a moodle site and port 57362 for database management.
Title: Re: Nginx as reverse proxy
Post by: fabian on December 25, 2018, 08:44:08 am
You need to create some upstream servers:

name: IP Port Priority
wordpress_server: server_1_ip 80 1
adminpanel_server: server_1_ip 8080 1
moodle_server: server_2_ip 80 1
dba_server: server_2_ip 57362 1

Next step: create an upstream for each server - you cannot reuse it because you are running a single web site/application behind a IP and port combination.

Next step: assign the right upstream to the location blocks of your configuration.

Now it should work.