# Rewrite URL

**URL:** <https://www.ruby-forum.com/t/rewrite-url/242585>\
**Category:** NGINX\
**Created:** [July 4, 2015, 8:38pm UTC](https://www.ruby-forum.com/t/rewrite-url/242585 "2015-07-04T20:38:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [July 4, 2015, 8:38pm UTC](https://www.ruby-forum.com/t/rewrite-url/242585/1 "2015-07-04T20:38:51Z")

</div>

Hello,

I try to use Nginx as a proxy (for SSL) on a Jetty server. The Jetty  
application should be accessed by a subdirectory of my Nginx. I have  
setup this location configuration:

location /myapp {

```
proxy_pass http://localhost:8112;

proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
#proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;  
proxy\_http\_version 1.1;  
proxy\_set\_header Upgrade $http\_upgrade;  
proxy\_set\_header Connection “upgrade”;  
client\_max\_body\_size 650M;

}

The Jetty server runs under [http://localhost:8112](http://localhost:8112), if I change the  
location /myapp to location / everything works fine. The Jetty server  
returns URLs with the base URL /, so on this configuration CSS / JSS  
files are not found.  
How can I rewrite the URLs, so that all files are found within the  
directory /myapp ?

Thanks

Phil

---

<div class="post-metadata">

**Author:** ![Philipp\_Kraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f1d935/32.png) [@Philipp\_Kraus](https://www.ruby-forum.com/u/Philipp_Kraus)\
**Post date:** [July 4, 2015, 8:54pm UTC](https://www.ruby-forum.com/t/rewrite-url/242585/2 "2015-07-04T20:54:37Z")

</div>

On 2015-07-04 11:38, Philipp Kraus wrote:

> ```
> #proxy_set_header X-Real-IP $remote_addr;
> 
> ```
> 
> Thanks
> 
> Phil

Hi Phil,

You should specify a URI (e.g., a trailing slash) in the URL specified  
by the proxy\_pass directive:

> location /myapp {
> 
> ```
> proxy_pass http://localhost:8112/;
> 
> ```

…

See [Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_pass) for more info.

Cheers,  
Constantine.
