Hello,
So I've had a fair bit of playing around with traefik and starting to get my head around things but attempting to troubleshoot this with GPT-4 and Claude 3 kept me going in circles.
I am currently running Proxmox and while I can get Traefik to reverse proxy me to the Web GUI just fine, I want the redirect to be prox.mydomain.com/?mobile=0 not just prox.mydomain.com. All attempts at trying to get this to happen have been fraught. In another environment where I'm using nginx I do the same thing for my Synology DSM re-route and it looks like this:
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name dsm.myotherdomain.com;
return 301 https://syno.myotherdomain.com/?forceDesktop=1;
}
For Traefik I have tried pathPrefix (just got a 404) and I tried a variety of middleware regex and path appends suggested by the LLMs but they all resulted in weird infinite loops where the url would come out to be prox.mydomain.com?/mobile=0?mobile=0?mobile=0?mobile=0?mobile=0?mobile=0?mobile=0 repeated.
Here are my relevant configs from my dynamic.toml. Any help or suggestions would be greatly appreciated as this works so easily in nginx
# Proxmox
[http.routers.proxmox-service]
rule = "Host(`prox.mydomain.com`,`proxmox.mydomain.com`)"
service = "proxmox-service"
entryPoints = ["websecure"]
[http.routers.proxmox-service.tls]
certresolver = "myresolver"
domains = [
{ main = "*.domain.com" }
]
# HTTP->HTTPS
[http.routers.http-catchall]
rule = "HostRegexp(`{any:.*}`)"
entryPoints = ["web"]
middlewares = ["redirect-https"]
service = "noop"
# Proxmox service pointing to your server's IP and port
[http.services.proxmox-service.loadBalancer]
serversTransport = "insecureskipverify"
[[http.services.proxmox-service.loadBalancer.servers]]
url = "https://192.168.32.2:8006"
# noop service
[http.services.noop.loadBalancer]
[[http.services.noop.loadBalancer.servers]]
url = "http://192.168.0.0"
[http.serversTransports]
[http.serversTransports.insecureskipverify]
insecureSkipVerify = true
[http.middlewares]
# HTTP->HTTPS
[http.middlewares.redirect-https.redirectScheme]
scheme = "https"
Editing to include the suggestions from the LLMs - This was repeated when I asked can't Traefik do a simple 301 redirect like nginx? And they gave me this suggestion:
#Add this middlewares to http.routers
middlewares = ["prox-redirect-with-query"]
# Middleware to redirect to the desired URL with ?mobile=0
[http.middlewares.prox-redirect-with-query.redirectregex]
regex = "^https?://(prox|proxmox)\\.mydomain\\.com(.*)"
replacement = "https://${1}.mydomain.com/?mobile=0${2}"
permanent = true
And again when I try that I get the infinite appending of ?mobile=0 to the end of the url after the /