# Use VPN for specific domains

**URL:** <https://forum.pritunl.com/t/use-vpn-for-specific-domains/1890>\
**Category:** Pritunl VPN\
**Created:** [March 9, 2024, 11:27pm UTC](https://forum.pritunl.com/t/use-vpn-for-specific-domains/1890 "2024-03-09T23:27:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric.price](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/e/71e660/32.png) [@eric.price](https://forum.pritunl.com/u/eric.price)\
**Post date:** [March 9, 2024, 11:27pm UTC](https://forum.pritunl.com/t/use-vpn-for-specific-domains/1890/1 "2024-03-09T23:27:45Z")

</div>

I have several services that are served by a CDN (cloudfront) so they are public. The current setup is to have all VPN traffic go through the instance so the WAF can only allow that specific IP to a specific domain (like [demo.companyinternal.com](http://demo.companyinternal.com)) on cloudfront. Saw the post below but wanted to verify that this is still not possible either on the server side or client side to only route traffic over the vpn when the domain matches.

> [@Routing on Domain](https://forum.pritunl.com/t/routing-on-domain/1228):
>
> Is there any way to route based on a domain/URL? We are using an AWS managed service that gives us an endpoint we want to route traffic through the VPN to it. The IPs behind this endpoint can change as it’s an AWS managed service so we don’t want to base routing rules off of them.

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [March 12, 2024, 10:24pm UTC](https://forum.pritunl.com/t/use-vpn-for-specific-domains/1890/2 "2024-03-12T22:24:09Z")

</div>

There’s still no option to route domains.

---

<div class="post-metadata">

**Author:** ![cesar](https://forum.pritunl.com/user_avatar/forum.pritunl.com/cesar/32/725_2.png) [@cesar](https://forum.pritunl.com/u/cesar)\
**Post date:** [March 13, 2024, 11:32am UTC](https://forum.pritunl.com/t/use-vpn-for-specific-domains/1890/3 "2024-03-13T11:32:42Z")

</div>

In my case, we needed only certain routes (specific domains) to go through the VPN. These routes were behind AWS load balancers (which change IP addresses from time to time).

We implemented monitoring on the LoadBalancer IPs using Zabbix, and as soon as a change is detected, a remote command is executed using the Pritunl API to shut down the server, remove the current routes (based on some comment, for example: “Route added via script”), resolve the LoadBalancer CNAME to the A record (IPs), and add these IPs as routes in the VPN.

It’s not the best of worlds, but it solved our problem.

---

<div class="post-metadata">

**Author:** ![gonzaloctorres](https://forum.pritunl.com/user_avatar/forum.pritunl.com/gonzaloctorres/32/974_2.png) [@gonzaloctorres](https://forum.pritunl.com/u/gonzaloctorres)\
**Post date:** [October 4, 2024, 3:32am UTC](https://forum.pritunl.com/t/use-vpn-for-specific-domains/1890/4 "2024-10-04T03:32:20Z")

</div>

> [@cesar](#):
>
> We implemented monitoring on the LoadBalancer IPs using Zabbix, and as soon as a change is detected, a remote command is executed using the Pritunl API to shut down the server, remove the current routes (based on some comment, for example: “Route added via script”), resolve the LoadBalancer CNAME to the A record (IPs), and add these IPs as routes in the VPN.
> 
> It’s not the best of worlds, but it solved our problem.

Could you share the commands you used in the API to stop the server and change/add the route?
