# Hide raw regular expression from $\_SERVER

**URL:** <https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074>\
**Category:** NGINX\
**Created:** [August 4, 2013, 12:08am UTC](https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074 "2013-08-04T00:08:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [August 4, 2013, 12:08am UTC](https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074/1 "2013-08-04T00:08:00Z")

</div>

I am using a regular expression in a server\_name:

```
     server_name ~^(?!web2\.)(?<account>.+)\.mydomain\.com$;

```

In PHP, or any language for that matter, if I:

```
    echo $_SERVER['server_name'];
    //~^(?!web2\.)(?.+)\.mydomain\.com$

```

I get the raw regular expression back. Is it possible to mask this, and  
instead return the actual regular expression matchedaccount? I.E.  
[foo.mydomain.com](http://foo.mydomain.com).

Posted at Nginx Forum:

> **[Hide raw regular expression from $\_SERVER\['server\_name'\]](https://forum.nginx.org/read.php?2,241519,241519#msg-241519)**
>
> I am using a regular expression in a server\_name: server\_name ~^(?!web2\\.)(?\<account\>.+)\\.mydomain\\.com$; In PHP, or any language for that matter, if I: echo $\_SERVER\['server\_name'\]; //~^(?!web2\\.)(?.+)\\.mydomain\\.com

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [August 4, 2013, 12:26am UTC](https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074/2 "2013-08-04T00:26:07Z")

</div>

On 3 Aug 2013 23:07, “justin” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I get the raw regular expression back. Is it possible to mask this, and  
> instead return the actual regular expression matchedaccount? I.E.  
> [foo.mydomain.com](http://foo.mydomain.com).

Have you tried looking at the “Host” HTTP header?

J

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [August 4, 2013, 2:07am UTC](https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074/3 "2013-08-04T02:07:10Z")

</div>

J,

The “HOST” http-header is correct, I am just wondering if I can modify  
or  
prevent the raw regular expression being exposed in  
$\_SERVER[‘server\_nam’].

Posted at Nginx Forum:

> **[Re: Hide raw regular expression from $\_SERVER\['server\_name'\]](https://forum.nginx.org/read.php?2,241519,241522#msg-241522)**
>
> I am using a regular expression in a server\_name: server\_name ~^(?!web2\\.)(?\<account\>.+)\\.mydomain\\.com$; In PHP, or any language for that matter, if I: echo $\_SERVER\['server\_name'\]; //~^(?!web2\\.)(?.+)\\.mydomain\\.com

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [August 4, 2013, 11:33am UTC](https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074/4 "2013-08-04T11:33:49Z")

</div>

On Aug 4, 2013, at 2:07 , justin wrote:

> instead return the actual regular expression matchedaccount? I.E.  
> [foo.mydomain.com](http://foo.mydomain.com).

You should change in your configuration the following string  
fastcgi\_param SERVER\_NAME $server\_name;  
to  
fastcgi\_param SERVER\_NAME $host;

–  
Igor S.

> **[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.

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [August 4, 2013, 11:15am UTC](https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074/5 "2013-08-04T11:15:08Z")

</div>

On 4 Aug 2013 01:07, “justin” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> J,
> 
> The “HOST” http-header is correct, I am just wondering if I can modify or  
> prevent the raw regular expression being exposed in  
> $\_SERVER[‘server\_nam’].

Why? The only meaningful information it could hold would be the same as  
that passed via the Host header. You already have that information. Just  
use the Host header.

J

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [August 4, 2013, 11:40am UTC](https://www.ruby-forum.com/t/hide-raw-regular-expression-from-server/236074/6 "2013-08-04T11:40:15Z")

</div>

Great fix Igor. Thanks.

Posted at Nginx Forum:

> **[Re: Hide raw regular expression from $\_SERVER\['server\_name'\]](https://forum.nginx.org/read.php?2,241519,241531#msg-241531)**
>
> I am using a regular expression in a server\_name: server\_name ~^(?!web2\\.)(?\<account\>.+)\\.mydomain\\.com$; In PHP, or any language for that matter, if I: echo $\_SERVER\['server\_name'\]; //~^(?!web2\\.)(?.+)\\.mydomain\\.com
