Karl's picture

I've got Traefik in a docker container in another Proxmox VM. It has been working great for other docker containers and even a few other VMs and devices.

However, when I point subdomain.domain.tld at my Traefik container which is configured to forward that subdomain to the IP address of my Zoneminder container, I start to have issues.

First, it does work for the "main" page (with links to webmin, etc.), but all of the buttons/links point to the internal IP address instead of the FQDN.

This seems like it should be simple, but I'm not sure whether it's a problem with the appliance (some setting I'm not finding), or if there's something I need to pass with Traefik so that the appliance knows that it's behind the proxy and handles it properly.

Does anyone have any insights? My domain is managed by Cloudflare, if that matters to anyone.

Jeremy Davis's picture

Just having a look through the build code and it doesn't seem that any domain/base URL is set anywhere by default, so I'm not sure why it's redirecting to the IP? Have you used it via IP initially at all? If so, perhaps it's cached that somewhere within Zoneminder (config? cache? DB?)? Perhaps try clearing all the Zoneminder cache(s) and see if that helps?

Failing that, I have a few ideas, but I strongly urge you to ensure that you have a working backup before following any of my wild guesses/suggestions below.

To check whether it's been stored within the zoneminder config (which I think is unlikely) you could try something like this (substitute the xxx's for the ip address - keep the slashes preceding the dots):

grep -R xxx\.xxx\.xxx\.xxx /etc/zm/

Zoneminder appears to cache stuff in /var/cache/zoneminder, so you could try a similar search there:

grep -R xxx\.xxx\.xxx\.xxx /var/cache/zoneminder

I'm not 100% sure on where Zoneminder stores it's data, but I'd assume mostly in the DB. So searching the DB might turn up something? Try this:

MYSQL="mysql  zm -s -e"
$MYSQL 'SHOW TABLES' | while read table; do echo "=== $table ==="; $MYSQL -B "SELECT * FROM $table" | grep xxx\.xxx\.xxx\.xxx

Again substitute the xxx's for the numbers of your server IP. This will show the table where the IP address occurs. Hopefully that will bring up something.

Assuming that you get a hit, then try swapping the FQDN for the IP address and see if that solves it.

Obviously the ideal is to try to work out where it's getting the IP from and fix it at the root cause. But if all else fails, you could use an Apache rewrite to always redirect to the domain. Personally, I would redirect http to https first, then you only need to rewrite direct https connection via IP. So to redirect http to https, within the VirtualHost *:80 section of /etc/apache2/sites-available/000-default.conf (replace YOUR.DOMAIN.COM with your actual domain):

    RedirectMatch ^(.*)$ https://YOUR.DOMAIN.COM$1

Then within the https section (i.e. 443 virtual host in the same apache config file):

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^xxx\.xxx\.xxx\.xxx$
    RewriteRule ^(.*)$ https://YOUR.DOMAIN.COM/$1 [L,R]

If you go that way and everything is working as it should, then you can make the redirect permanent by substituting the 'R' (near the end of the last line I noted above) for 'R=308' - i.e. so it will read: '[L,R=308]'.

Add new comment