# Trailing slash in location

**URL:** <https://www.ruby-forum.com/t/trailing-slash-in-location/224599>\
**Category:** NGINX\
**Created:** [November 18, 2012, 2:25pm UTC](https://www.ruby-forum.com/t/trailing-slash-in-location/224599 "2012-11-18T14:25:28Z")\
**Posts on this page:** 2\
**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:** [November 18, 2012, 2:25pm UTC](https://www.ruby-forum.com/t/trailing-slash-in-location/224599/1 "2012-11-18T14:25:28Z")

</div>

Please help me understand

The below works

```
 location /stats/ {
    proxy_pass http://example.com;
 }

```

or

```
 location /stats {
    proxy_pass http://example.com;
 }

```

or

```
 location /stats {
    proxy_pass http://example.com/stats;
 }

```

or

```
 location /stats {
    proxy_pass http://example.com/stats/;
 }

```

or

```
 location /stats/ {
    proxy_pass http://example.com/stats/;
 }

```

But this does not work

```
 location /stats/ {
    proxy_pass http://example.com/stats;
 }

```

Smlly when stats is an upstream

This works

location /stats {  
proxy\_pass [http://stats](http://stats);  
}

but this does not

location /stats {  
proxy\_pass [http://stats/](http://stats/);  
}

What difference it makes when we have uri in the proxy\_pass?

Posted at Nginx Forum:

> **[trailing slash in location](https://forum.nginx.org/read.php?2,232966,232966#msg-232966)**
>
> Please help me understand The below works location /stats/ { proxy\_pass http://example.com; } or location /stats { proxy\_pass http://example.com; } or

---

<div class="post-metadata">

**Author:** ![amodpandey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@amodpandey](https://www.ruby-forum.com/u/amodpandey)\
**Post date:** [November 18, 2012, 4:10pm UTC](https://www.ruby-forum.com/t/trailing-slash-in-location/224599/2 "2012-11-18T16:10:02Z")

</div>

On Nov 18, 2012, at 17:25 , amodpandey wrote:

> ```
> location /stats {
> 
> ```
> 
> But this does not work  
> proxy\_pass [http://stats](http://stats);  
> }
> 
> but this does not
> 
> location /stats {  
> proxy\_pass [http://stats/](http://stats/);  
> }

It should work. Probably “/stats/” \> “/stats” does not work.

> What difference it makes when we have uri in the proxy\_pass?

It does not work because nginx changes /stats/SOME/PAGE to  
/statsSOME/PAGE.

Please read for details:

> **[Module ngx\_http\_proxy\_module](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass)**
>
> The ngx\_http\_proxy\_module module allows passing requests to another server.

–  
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.
