# Proxying with/without listen in server block

**URL:** <https://www.ruby-forum.com/t/proxying-with-without-listen-in-server-block/246025>\
**Category:** NGINX\
**Created:** [August 14, 2013, 11:09am UTC](https://www.ruby-forum.com/t/proxying-with-without-listen-in-server-block/246025 "2013-08-14T11:09:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [August 14, 2013, 11:09am UTC](https://www.ruby-forum.com/t/proxying-with-without-listen-in-server-block/246025/1 "2013-08-14T11:09:34Z")

</div>

Does having a listen directive in a server block over ride blocks  
without?

I have a slightly complex set up, proxying traffic depending on url to  
various other machines on the network.

Something a bit like this: [Nginx Proxy Settings - Pastebin.com](http://pastebin.com/MSAFJKLV)

The middle block hogs all the traffic, and all requests are sent to  
[mysssl.example.com](http://mysssl.example.com).

What am I missing?

Posted at Nginx Forum:

> **[Proxying with/without listen in server block](https://forum.nginx.org/read.php?2,241824,241824#msg-241824)**
>
> Does having a listen directive in a server block over ride blocks without? I have a slightly complex set up, proxying traffic depending on url to various other machines on the network. Something a bit like this: http://pastebin.com/MSAFJKLV The...

---

<div class="post-metadata">

**Author:** ![tcbarrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tcbarrett](https://www.ruby-forum.com/u/tcbarrett)\
**Post date:** [August 14, 2013, 11:49am UTC](https://www.ruby-forum.com/t/proxying-with-without-listen-in-server-block/246025/2 "2013-08-14T11:49:17Z")

</div>

Am I missing this:

“If a server is the only server for a listen port, then nginx will not  
test  
server names at all (and will not build the hash tables for the listen  
port). However, there is one exception. If a server name is a regular  
expression with captures, then nginx has to execute the expression to  
get  
the captures.”

[http://nginx.org/en/docs/http/server\_names.html](http://nginx.org/en/docs/http/server_names.html)

Posted at Nginx Forum:

> **[Re: Proxying with/without listen in server block](https://forum.nginx.org/read.php?2,241824,241826#msg-241826)**
>
> Does having a listen directive in a server block over ride blocks without? I have a slightly complex set up, proxying traffic depending on url to various other machines on the network. Something a bit like this: http://pastebin.com/MSAFJKLV The...

---

<div class="post-metadata">

**Author:** ![tcbarrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tcbarrett](https://www.ruby-forum.com/u/tcbarrett)\
**Post date:** [August 14, 2013, 12:51pm UTC](https://www.ruby-forum.com/t/proxying-with-without-listen-in-server-block/246025/3 "2013-08-14T12:51:46Z")

</div>

On Wed, Aug 14, 2013 at 05:48:38AM -0400, tcbarrett wrote:

Hi there,

> Am I missing this:

I think you’re missing this:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html#mixed_name_ip_based_servers)**
>
> nginx first decides which server should process the request. Let’s start with a simple configuration where all three virtual servers listen on port \*:80:

coupled with the default value for “listen”, as in “what is meant by not  
having a listen in a server block”, which is at

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#listen)**
>
> This directive appeared in version 1.11.8.

The answer to your original question:

> Does having a listen directive in a server block over ride blocks without?

is “yes, if the listen directive is different from the default”.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
