# Reverse proxy using nginx as frontend server

**URL:** <https://www.ruby-forum.com/t/reverse-proxy-using-nginx-as-frontend-server/191193>\
**Category:** NGINX\
**Created:** [July 7, 2010, 11:42am UTC](https://www.ruby-forum.com/t/reverse-proxy-using-nginx-as-frontend-server/191193 "2010-07-07T11:42:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Retheesh\_Kumar\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bc8723/32.png) [@Retheesh\_Kumar\_R](https://www.ruby-forum.com/u/Retheesh_Kumar_R)\
**Post date:** [July 7, 2010, 11:42am UTC](https://www.ruby-forum.com/t/reverse-proxy-using-nginx-as-frontend-server/191193/1 "2010-07-07T11:42:30Z")

</div>

Hello All,

I am trying to configure reverse proxy on my nginx server. This server  
need to sit in the DMZ zone. Receive the web request and forward it to a  
backend web server.

I have tried the configuration mentioned here.  
[http://wiki.nginx.org/NginxLikeApache](http://wiki.nginx.org/NginxLikeApache)

Note: - Currently No firewall in place so no port restriction.

Scenario -

The frontend server URL is [https://mail.example.com](https://mail.example.com)

Backend Web Server URL is [https://mail.webserver.com](https://mail.webserver.com)

Challenges -

- 

```
    When the redirect happens the frontend URL should not change.

```

It should remain the same appending the new page details to the frontend  
server URL.

- 

```
    Need https configured from Client to frontend

```

- 

```
    https/http from frontend to backend web server.

```

Can you please guide me with the configuration. Or let me know if you  
need any further information

Regards,

Retheesh

The information transmitted is intended only for the person or entity to  
which it is addressed and may contain confidential and/or privileged  
material.  
Any review, re-transmission, dissemination or other use of or taking of  
any action in reliance upon,this information by persons or entities  
other than the intended recipient is prohibited.  
If you received this in error, please contact the sender and delete the  
material from your computer.  
Microland takes all reasonable steps to ensure that its electronic  
communications are free from viruses.  
However, given Internet accessibility, the Company cannot accept  
liability for any virus introduced by this e-mail or any attachment and  
you are advised to use up-to-date virus checking software.

---

<div class="post-metadata">

**Author:** ![Retheesh\_Kumar\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bc8723/32.png) [@Retheesh\_Kumar\_R](https://www.ruby-forum.com/u/Retheesh_Kumar_R)\
**Post date:** [July 10, 2010, 3:59am UTC](https://www.ruby-forum.com/t/reverse-proxy-using-nginx-as-frontend-server/191193/2 "2010-07-10T03:59:15Z")

</div>

Retheesh Kumar R wrote:

> Hello All,
> 
> I am trying to configure reverse proxy on my nginx server. This server  
> need to sit in the DMZ zone. Receive the web request and forward it to a  
> backend web server.
> 
> I have tried the configuration mentioned here.  
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxLikeApache)
> 
> Note: - Currently No firewall in place so no port restriction.
> 
> Scenario -
> 
> The frontend server URL is [https://mail.example.com](https://mail.example.com)
> 
> Backend Web Server URL is [https://mail.webserver.com](https://mail.webserver.com)
> 
> Challenges -
> 
> - 
> 
> ```
> When the redirect happens the frontend URL should not change.
> 
> ```
> 
> It should remain the same appending the new page details to the frontend  
> server URL.
> 
> - 
> 
> ```
> Need https configured from Client to frontend
> 
> ```
> 
> - 
> 
> ```
> https/http from frontend to backend web server.
> 
> ```
> 
> Can you please guide me with the configuration. Or let me know if you  
> need any further information
> 
> Regards,
> 
> Retheesh
> 
> The information transmitted is intended only for the person or entity to  
> which it is addressed and may contain confidential and/or privileged  
> material.  
> Any review, re-transmission, dissemination or other use of or taking of  
> any action in reliance upon,this information by persons or entities  
> other than the intended recipient is prohibited.  
> If you received this in error, please contact the sender and delete the  
> material from your computer.  
> Microland takes all reasonable steps to ensure that its electronic  
> communications are free from viruses.  
> However, given Internet accessibility, the Company cannot accept  
> liability for any virus introduced by this e-mail or any attachment and  
> you are advised to use up-to-date virus checking software.

This is about what your looking for, although it only does plain-text  
conversations from front-end to origin machines.

#Start of nginx config for SSL offloading  
…  
…  
upstream app\_pool {  
server 192.168.1.100:80; # change these ports to connect to  
SSL backend(s) instead?  
server 192.168.1.101:80;  
}

server {  
ssl on;  
ssl\_certificate /etc/ssl/nginx/secure\_combined.crt;  
ssl\_certificate\_key  
/etc/ssl/nginx/secure.some-domain-name-ssl-cert.com.key;

```
    listen 443;
    location / {
    proxy_pass http://app_pool; # possible to use ports 

```

here..ie http://app\_pool:443;  
port\_in\_redirect off; # toggle on/off if you use a port  
in the above line  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For  
$proxy\_add\_x\_forwarded\_for;  
}  
}  
}

# End of Nginx config

Essentially, this config would listen on 443 of a machine, and pass all  
requests to the two backends that are mentioned in the upstream block  
above server. In this config, a user makes a connection via SSL to  
[https://thismachine.com](https://thismachine.com), and the request is sent to the back-end as  
plain-text(no ssl)

I would say you can use the “proxy\_pass” statement in the server area to  
try and connect to the origin machine(s) via SSL, as you can specify  
ports in proxy\_pass like this…

proxy\_pass [http://localhost:8080](http://localhost:8080)

Not exactly what you were looking for, but a few minutes of  
experimenting with the proxy pass ports and upstream nodes, and you  
should have what you want running.

Thanks!
