# Condensing Location Directives

**URL:** <https://www.ruby-forum.com/t/condensing-location-directives/221642>\
**Category:** NGINX\
**Created:** [July 23, 2012, 7:37pm UTC](https://www.ruby-forum.com/t/condensing-location-directives/221642 "2012-07-23T19:37:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 23, 2012, 7:37pm UTC](https://www.ruby-forum.com/t/condensing-location-directives/221642/1 "2012-07-23T19:37:52Z")

</div>

I have this setup for my location directives

```
location /css/ {
  proxy_pass http://127.0.0.1:8080/css/;
}

location /js/ {
  proxy_pass http://127.0.0.1:8080/js/;
}

```

It seems a bit repetitive to me, is it possible to do something like  
this.

```
location /css/, /js/ {
  proxy_pass http://127.0.0.1:8080/$1;
}

```

Where you can have one block process multiple locations, then the  
variable $1, copies the location defined into the proxy\_pass URL? I  
might have about 10-20 and it would be easier to have one block then 20.

Posted at Nginx Forum:

> **[Condensing Location Directives](https://forum.nginx.org/read.php?2,228898,228898#msg-228898)**
>
> I have this setup for my location directives location /css/ { proxy\_pass http://127.0.0.1:8080/css/; } location /js/ { proxy\_pass http://127.0.0.1:8080/js/; } It seems a bit repetitive to me, is it possible to d

---

<div class="post-metadata">

**Author:** ![arosolino](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9e8a1a/32.png) [@arosolino](https://www.ruby-forum.com/u/arosolino)\
**Post date:** [July 27, 2012, 3:26pm UTC](https://www.ruby-forum.com/t/condensing-location-directives/221642/2 "2012-07-27T15:26:29Z")

</div>

It’s possible to use regex, such as:

location ~ ^/(?[^/]+)/ {  
proxy\_pass [http://127.0.0.1:8080/$type/](http://127.0.0.1:8080/$type/);  
}

BUT two static (non-regex) locations are faster.

Andrejs

Posted at Nginx Forum:

> **[Re: Condensing Location Directives](https://forum.nginx.org/read.php?2,228898,229038#msg-229038)**
>
> I have this setup for my location directives location /css/ { proxy\_pass http://127.0.0.1:8080/css/; } location /js/ { proxy\_pass http://127.0.0.1:8080/js/; } It seems a bit repetitive to me, is it possible to d

---

<div class="post-metadata">

**Author:** ![arosolino](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9e8a1a/32.png) [@arosolino](https://www.ruby-forum.com/u/arosolino)\
**Post date:** [July 27, 2012, 3:50pm UTC](https://www.ruby-forum.com/t/condensing-location-directives/221642/3 "2012-07-27T15:50:29Z")

</div>

I agree with you there on speed which I am not willing to sacrifice,  
then maybe ill just submit this as a feature request.

Posted at Nginx Forum:

> **[Re: Condensing Location Directives](https://forum.nginx.org/read.php?2,228898,229039#msg-229039)**
>
> I have this setup for my location directives location /css/ { proxy\_pass http://127.0.0.1:8080/css/; } location /js/ { proxy\_pass http://127.0.0.1:8080/js/; } It seems a bit repetitive to me, is it possible to d
