# HAProxy rewrite URL

**URL:** <https://discourse.haproxy.org/t/haproxy-rewrite-url/914>\
**Category:** Help!\
**Created:** [January 5, 2017, 11:34am UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914 "2017-01-05T11:34:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppraj](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@ppraj](https://discourse.haproxy.org/u/ppraj)\
**Post date:** [January 5, 2017, 11:34am UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/1 "2017-01-05T11:34:05Z")

</div>

Jenkins listens on 192.168.2.57:9000 . Now my HAPROxy configured on another machine is has been updated with virtual path

```
   frontend http-in
    bind *:80
    option http-server-close
    option forwardfor
    acl has_jenkins path_beg /jenkins
    use_backend jenkins_server if has_jenkins

backend jenkins_server
balance roundrobin
option forwardfor
server jenkins 192.168.2.57:9000

```

When I hit /jenkins , page come up with BAD REQUEST. The issue is the actual server does not serve with /jenkins. Hence I need to strip /jenkins and send the request to backend . So I did this

```
reqrep ^([^\]*\ /)jenkins[/]?(.*) \1\2

```

The page does not load either , but now no BAD REQUEST . Instead I just get blank page , but when I press F12 I can see in the console and the request headers coming up . The URL now in there /css , which is not good as it needs to be 192.168.2.57:9000/css , to make it work .

The links in the page still points to , which is not the actual server where it is hosted and fails subsequently

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [January 5, 2017, 1:00pm UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/2 "2017-01-05T13:00:48Z")

</div>

> [@ppraj](#):
>
> The URL now in there /css , which is not good as it needs to be 192.168.2.57:9000/css , to make it work .

No, you are confusing path with the URL. The IP address and port are not part of the GET request.

---

<div class="post-metadata">

**Author:** ![ppraj](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@ppraj](https://discourse.haproxy.org/u/ppraj)\
**Post date:** [January 5, 2017, 1:09pm UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/3 "2017-01-05T13:09:59Z")

</div>

See this grab from Chrome browser console . This is how the links show up when you browse the application using the local IP where it is hosted , hence when you browse usign HAPROXY , it needs to send the request to backend as this , but it replaces with HAPROXYIP

```
Request URL:http://192.168.2.57:9000/js/vendor.js
Request Method: GET
```

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [January 5, 2017, 2:12pm UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/4 "2017-01-05T14:12:32Z")

</div>

Here the path is:

> /js/vendor.js

which translate to a get request like this:

> GET /js/vendor.js HTTP/1.1

Do you need a particular Host header perhaps?

---

<div class="post-metadata">

**Author:** ![ppraj](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@ppraj](https://discourse.haproxy.org/u/ppraj)\
**Post date:** [January 6, 2017, 7:13am UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/5 "2017-01-06T07:13:07Z")

</div>

As you see , my calls should translate to the actual application IP . Not sure how that can be done

---

<div class="post-metadata">

**Author:** ![ppraj](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@ppraj](https://discourse.haproxy.org/u/ppraj)\
**Post date:** [January 9, 2017, 2:21pm UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/6 "2017-01-09T14:21:33Z")

</div>

@lukastribus , any update on the above . I need this to work as reverse proxy

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [January 9, 2017, 2:51pm UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/8 "2017-01-09T14:51:38Z")

</div>

This is a public forum, please remove those credentials immediately for your own safety.

All I can do is suggest haproxy configurations when you know what you configuration/architecture requires.

Since you don’t, I suggest you hire somebody who can or get enterprise support from [haproxy.com](http://haproxy.com); but I am unable to troubleshoot your backend applications.

---

<div class="post-metadata">

**Author:** ![ppraj](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@ppraj](https://discourse.haproxy.org/u/ppraj)\
**Post date:** [January 9, 2017, 4:14pm UTC](https://discourse.haproxy.org/t/haproxy-rewrite-url/914/9 "2017-01-09T16:14:38Z")

</div>

@lukastribus, thanks for reminding,have withdrawn the post.

The application itself does not accept any prefix .It does listen only on port .  
But my need is to custom wire URL with a prefix for user.
