# Proxy Pass To Dynamic DNS



## Geezer (Jul 14, 2021)

I am using apache24 as a proxy (amongst other stuff) using:


```
<VirtualHost public.domain.name xx.xx.xx.xx:80>
    ProxyPass / http://dynamic.domain.name:8800/
    ProxyPassReverse / http://dynamic.domain.name:8800/
</VirtualHost>
```

This works very well, except dynamic.domain.name is used for a domestic machine, is dynamic and the IP address changes once or twice a day.

When the IP changes, then apache gives a 503 error when connecting to public.domain.name.

I can clear this by `service apache24 restart`/`reload`/`graceful`, but I want this to be automated.

For the time being, I can do this with a `crontab` that `drill`s dynamic.domain.name and if it changes then do the `service apache24 graceful`, but it is not an elegant solution.

Is there anything better? Is there anything within apache that will recognise when dynamic.domain.name changes?


----------



## covacat (Jul 14, 2021)

you can use a "program" rewrite map which can return the valid ip
then something like this

```
RewriteEngine On
        RewriteMap d2u "prg:/var/www/html/whatever.sh"
        RewriteRule .* - [E=ZPROXY:${d2u:%{HTTP_HOST}|dynamic.domain.name}]
        ProxyPreserveHost On
        ProxyPassInterpolateEnv On
        ProxyPassReverse / https://${ZPROXY}:443/ interpolate
        ProxyPass / https://${ZPROXY}:443/ interpolate
```


----------

