# Haproxy redirect on 443

**URL:** <https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005>\
**Category:** Help!\
**Created:** [September 17, 2018, 2:20pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005 "2018-09-17T14:20:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mysticalunicorn](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mysticalunicorn](https://discourse.haproxy.org/u/mysticalunicorn)\
**Post date:** [September 17, 2018, 2:20pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/1 "2018-09-17T14:20:46Z")

</div>

I was using .htaccess to redirect users to cloud.

Here is my config in apache mod.i put in some dummy urls. it needs to redirect on port 443.  
I need to switch over to Ha Proxy, I am using the latest stable haproxy. 1.8

> Options +FollowSymLinks  
> RewriteEngine on  
> RewriteRule ^token._$ [https://123.testing.io:443/oauth/token](https://123.testing.io:443/oauth/token) [R=301,L]  
> RewriteRule ^test2._$ [https://345.testing.io:443/svc/device/dev?limit=100](https://345.testing.io:443/svc/device/dev?limit=100) [R=301,L]  
> RewriteRule ^test3.\*$ https:/456.testing.io:443/svc/v1/com/devices [R=307,L]

so basically when someone goes to the server with /token it forwards them to the cloud url on port 443. The requests are also being sent on port 443.  
cant figure out how to get these to work in haproxy. backend needs IP not url.  
These urls are in aws cloud, I cannot use IP address only url.  
can someone assist please.  
thank you.

---

<div class="post-metadata">

**Author:** ![mysticalunicorn](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mysticalunicorn](https://discourse.haproxy.org/u/mysticalunicorn)\
**Post date:** [September 18, 2018, 2:28pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/2 "2018-09-18T14:28:22Z")

</div>

anyone got any ideas ?

---

<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:** [September 18, 2018, 3:41pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/3 "2018-09-18T15:41:30Z")

</div>

I don’t know what this apache configuration does.

> [@mysticalunicorn](#):
>
> it needs to redirect on port 443.

```auto
redirect scheme https if !{ ssl_fc }

```

> [@mysticalunicorn](#):
>
> when someone goes to the server with /token it forwards them to the cloud url on port 443.

What’s a cloud URL?

> [@mysticalunicorn](#):
>
> backend needs IP not url.  
> These urls are in aws cloud, I cannot use IP address only url.

Are you trying to say that in the haproxy backend configuration you can only put ip addresses and your backend will be AWS with hostnames?

Actually you can use hostnames and configure [dynamic DNS resolution](https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5.3).

---

<div class="post-metadata">

**Author:** ![mysticalunicorn](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mysticalunicorn](https://discourse.haproxy.org/u/mysticalunicorn)\
**Post date:** [September 18, 2018, 4:02pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/4 "2018-09-18T16:02:46Z")

</div>

correct.  
I do not have an IP address to forward to. I only have the urls.  
And what I have read in the backend you can only put an IP, and I do not have IP addresses in AWS, only urls.

cloud url is just the url to the cloud site. no IP address.

---

<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:** [September 19, 2018, 11:14am UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/5 "2018-09-19T11:14:01Z")

</div>

You can use hostnames and use the DNS resolver, as explained above.

---

<div class="post-metadata">

**Author:** ![mysticalunicorn](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mysticalunicorn](https://discourse.haproxy.org/u/mysticalunicorn)\
**Post date:** [September 19, 2018, 11:48am UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/6 "2018-09-19T11:48:56Z")

</div>

ok. is there a way to redirect the urls without using a backend ?

---

<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:** [September 19, 2018, 12:48pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/7 "2018-09-19T12:48:40Z")

</div>

Yes, use the [http-request redirect](https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#redirect) option.

---

<div class="post-metadata">

**Author:** ![mysticalunicorn](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mysticalunicorn](https://discourse.haproxy.org/u/mysticalunicorn)\
**Post date:** [September 19, 2018, 12:53pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/8 "2018-09-19T12:53:37Z")

</div>

this option works with https ?  
the requests are being sent to port 443 on https, and forwarded on the same. Doesnt that work with just http ?

---

<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:** [September 19, 2018, 12:55pm UTC](https://discourse.haproxy.org/t/haproxy-redirect-on-443/3005/9 "2018-09-19T12:55:59Z")

</div>

When you _terminate_ SSL on haproxy (meaning you have the certificate and the private key and use it in haproxy), and you are in http mode, then you can do everything.

When you don’t _terminate_ SSL, there is no way to intercept, redirect or do anything with the request (other than forwarding plain TCP with encrypted SSL).
