# About Nginx as reverse proxy?



## max21 (Mar 5, 2017)

Hello everyone,

After playing with nearly _all_, the very few complicated how-to’s created strictly for FreeBSD, I found the simplest one to use Nginx as reverse proxy but I still don’t have a clue of tools or alliances needed to test on a single machine.  I don’t want to place everything in one jail because I may want to move these same jails to multiple servers someday.  If I get the hang of things, then only minimal modification will be needed.

For now I’m trying to deal with two or more jails on the same machine; one for Nginx-Reverse-Proxy and the other with Apache with PHP.  When I test each jail separately, they work.  So I am half way there if there is a there.

*Nginx on IP-10.0.0.1 is working:*

```
Performing sanity check on nginx configuration:  …
Starting nginx.
#
```

*Apache on IP-10.0.0.4 is working:*

```
Performing sanity check on php-fpm configuration:  …
Starting php_fpm.

Performing sanity check on apache24 configuration: …
Starting apache24.
#
```

Calling from Firefox on the host, It works like a charm separately:

```
http://10.0.0.1:8080/
http://10.0.0.4:8080/info.php
```

How would I pass real-ips to apache or any other backend server?   Can I fake real-ip with my virtual IP 10.x.x.x?  How would I go about testing all of this on a single FreeBSD machine?  I hope I am not completely off base, because no tutors I read don’t even mention something like this, ether because it’s not possible or they figure it should be common knowledge.

***** https://techknight.eu/2015/08/13/let-nginx-reverse-proxy-pass-real-ips-to-apache/

https://www.knthost.com/nginx/nginx-reverse-proxy-setup-freebsd
http://linoxide.com/linux-how-to/install-nginx-reverse-proxy-apache-freebsd-10-2/
http://docplayer.net/5955106-Running-nginx-as-reverse-proxy-server.html
http://www.howdididothat.info/2013/...che-for-all-domains-on-other-virtual-machine/
https://www.quora.com/Whats-the-difference-between-a-reverse-proxy-and-forward-proxy
http://selby.highfield-house.org.uk/?cat=9
http://kbeezie.com/apache-with-nginx/

Other than what’s here and at GIT, that’s just about all she wrote for FreeBSD


----------



## Tabs (Mar 6, 2017)

What I would do is have a single nginx facing the internet with your real IP and have that reverse proxy to your other jailed nginx instances using virtual hosts.

With regards to testing it on a single machine, if you have a single nginx with your real IP then you can just use the loopback adapter for your backend nginx and application servers.

Hope that helps, I'm not too clear on the question to be honest


----------



## max21 (Mar 6, 2017)

Exactly what I needed to hear.  I was trying to avoid facing the INTERNET with my IP and figure out how to do the loop-back thing.  i'm going to rent a cheap VPS and learn from there like everybody else.  Thanks a zillion Tabs@.  This is so interesting, I think I’ll try this first



Tabs said:


> What I would do is have a single nginx facing the internet with your real IP and have that reverse proxy to your other jailed nginx instances using virtual hosts.


----------

