# Reverse proxy and rewrite

**URL:** <https://www.ruby-forum.com/t/reverse-proxy-and-rewrite/226844>\
**Category:** NGINX\
**Created:** [February 22, 2013, 10:16pm UTC](https://www.ruby-forum.com/t/reverse-proxy-and-rewrite/226844 "2013-02-22T22:16:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jims](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/838e76/32.png) [@jims](https://www.ruby-forum.com/u/jims)\
**Post date:** [February 22, 2013, 10:16pm UTC](https://www.ruby-forum.com/t/reverse-proxy-and-rewrite/226844/1 "2013-02-22T22:16:36Z")

</div>

nginx 1.2.7 on CentOS 6.3. Reverse-proxy with two upstream servers.  
One  
server should be default, the other should only be used when called from  
a  
link on a specific web server.

I have the reverse proxy working fine for the default upstream, but not  
quite right on the second, site-specific upstream. Ignoring that I am  
also  
rewriting for http to force https (yeah, I know, it’s discouraged to go  
encrypted between the nginx proxy and its upstreams, but it’s a  
corporate  
security thing) I am using a two server block configuration, one server  
name  
for the default and another for the site-specific server. The  
site-specific  
server will link to the default server URL but should rewrite to the  
site-specific upstream’s proxy’s URL.

It seems to work - not sure if it gets stuck in the proxy or on the  
upstream  
for the site-specific setup -, but it was suggested that a single  
server,  
selecting between upstream servers, would be preferable. I would like  
to  
know how that would be configured - just a quick overview or link to a  
documentation page would help a lot.

If I can throw together a quick test of a single-server-block  
reverse-proxy  
config with multiple upstreams which are selected based on calling  
server, I  
could test to see if it’s my multi-server-block setup or a problem on  
the  
upstream.

Thanks!

Jim.

Posted at Nginx Forum:

> **[Reverse proxy and rewrite](https://forum.nginx.org/read.php?2,236487,236487#msg-236487)**
>
> nginx 1.2.7 on CentOS 6.3. Reverse-proxy with two upstream servers. One server should be default, the other should only be used when called from a link on a specific web server. I have the reverse proxy working fine for the default upstream, but not...

---

<div class="post-metadata">

**Author:** ![jims](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/838e76/32.png) [@jims](https://www.ruby-forum.com/u/jims)\
**Post date:** [February 23, 2013, 1:15am UTC](https://www.ruby-forum.com/t/reverse-proxy-and-rewrite/226844/2 "2013-02-23T01:15:34Z")

</div>

Hello!

On Fri, Feb 22, 2013 at 04:16:03PM -0500, jims wrote:

> server will link to the default server URL but should rewrite to the  
> could test to see if it’s my multi-server-block setup or a problem on the  
> upstream.

Normal nginx aproach is to use distinct server blocks for servers  
with different configuration.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
