I'm trying to write a rewrite rule for Zimbra, which will allow me to use a hostname to access the Zimbra Desktop Web UI instead of the IP address and port.
The default Zimbra URLs are like this:
http://127.0.0.1:port/?at=long-encrypted-user-id
http://127.0.0.1:port/zimbra/?at=long-encrypted-user-id
http://127.0.0.1:port/desktop/login.jsp?at=long-encrypted-user-id
Here's what I have till now:
server {
server_name hostname;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:port/;
}
}
This only replaces http://hostname
by http://127.0.0.1:port
in the background; Where I'm stuck is adding the ?at=long-encrypted-user-id
to the URLs. Can somebody help?
OK, so if anyone needs this in the future, I just had to add an if and a rewrite:
and the final server block becomes
Nginx warns against using
if
(IfIsEvil), but not if you addlast
to the rewrite.