# Proxy\_pass with runtime variables?

**URL:** <https://www.ruby-forum.com/t/proxy-pass-with-runtime-variables/186211>\
**Category:** NGINX\
**Created:** [April 2, 2010, 6:01am UTC](https://www.ruby-forum.com/t/proxy-pass-with-runtime-variables/186211 "2010-04-02T06:01:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quan\_Zhou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/edb3f5/32.png) [@Quan\_Zhou](https://www.ruby-forum.com/u/Quan_Zhou)\
**Post date:** [April 2, 2010, 6:01am UTC](https://www.ruby-forum.com/t/proxy-pass-with-runtime-variables/186211/1 "2010-04-02T06:01:32Z")

</div>

Hi all,

I’m having issues with reverse proxy on Nginx

I was setting up a reverse proxy listening [::0]:80 acts as 6 to 4  
server on  
Nginx, so I’ve tried $host, $server\_name, $http\_host in proxy\_pass  
field,  
but they all failed, and server threw same error:

[emerg]: invalid number of arguments in “proxy\_pass” directive in  
/etc/nginx/sites-enabled/reverse.proxy:16

Here’s my configuration file:

server {  
listen [::0]:80;  
server\_name _._;

```
    access_log off;
    error_log off;

    location /{
            proxy_pass $server_name
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;

```
            client_max_body_size 10m;
            client_body_buffer_size 128k;

            proxy_connect_timeout 90;
            proxy_send_timeout 90;
            proxy_read_timeout 90;

            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_seze 64k;

     }

```

}

I want to know is that possible to get every site to be reverse proxied  
on  
Nginx?

Thanks:)

Quan Zhou

---

<div class="post-metadata">

**Author:** ![Quan\_Zhou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/edb3f5/32.png) [@Quan\_Zhou](https://www.ruby-forum.com/u/Quan_Zhou)\
**Post date:** [April 2, 2010, 10:04am UTC](https://www.ruby-forum.com/t/proxy-pass-with-runtime-variables/186211/2 "2010-04-02T10:04:56Z")

</div>

On Fri, Apr 02, 2010 at 12:00:01PM +0800, Quan Zhou wrote:

> /etc/nginx/sites-enabled/reverse.proxy:16
> 
> Here’s my configuration file:
> 
> server {  
> listen [::0]:80;  
> server\_name _._;

“_._” is invalid server\_name.

> ```
> access_log off;
> error_log off;
> 
> location /{
> proxy_pass $server_name
> 
> ```

- 

```
            proxy_pass $server_name

```

- 

```
            proxy_pass $server_name;

```

or probably

- 

```
            proxy_pass $server_name

```

- 

```
            proxy_pass $host;

```

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Quan\_Zhou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/edb3f5/32.png) [@Quan\_Zhou](https://www.ruby-forum.com/u/Quan_Zhou)\
**Post date:** [April 2, 2010, 3:36pm UTC](https://www.ruby-forum.com/t/proxy-pass-with-runtime-variables/186211/3 "2010-04-02T15:36:12Z")

</div>

Thank you for your reply, igor.  
I’ve corrected server name field with a ‘\_’ (and tried $host  
$http\_host later), and both $server\_name and $host can pass the  
grammar check, it doesn’t work finally, actually, it returns a cacti  
page on my server for any request, I’ve checked entire configuration  
files, cacti is only assigned to a domain name but bind to [::]:80,  
however, I don’t think this caused cacti has highier priority …  
:confused

Quan Zhou  
Sent from my Windows® phone.
