Rewriting parts of arguments in a URL

So for the moment, I’m having a little issue, and I’m not sure if there’s a way to do this, or if this is very specific to how I’m trying to accomplish this.

I currently have a URL from an application I’m running behind a reverse proxy providing the following:

https://example.com/portal/svr/loadapp.php?devtype=mline&action=log&real_action=play&param=http%253A%252F%252F10.254.4.8%253A34400%252Fstream%252F53ab96abc01a82fdb6ec721b292858cf&content_id=339&tmp_type=1&JsHttpRequest=1-xml

If you notice, theres an argument for param that is a local IP URL. Is there any way to, say, take out the 10.254.4.8 from that and change to the public IP of the server, even if I have to hard-code it into the rewrite?

Hi @miguelr, welcome to the Caddy community.

This should be possible, especially if you’re willing to hardcode it.

What’s your caddy -version ?

@Whitestrake

Caddy v1.0.3 (h1:i9gRhBgvc5ifchwWtSe7pDpsdS9+Q0Rw9oYQmYUTw1w=)

The rewrite docs are here:

https://caddyserver.com/v1/docs/rewrite

You’ll want to rewrite with a regexp that captures the variable parts of the URL and write the target URL with the correct IP address.

If you include a substring check like if {uri} has 10.254.4.8, you’ll save your web server a few ticks of processing power running regex checks on all your requests.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.