Changing nginx config to caddy!

I am trying to configure my Caddyfile … coming from an existing nginx setup. Here is my issue that I need help with.

I am trying to rewrite this bit

location ~* (\.cfm|\.cfc)$ {
	import lucee-proxy.conf;

	if ($sub){
		rewrite ^/(.*\.cf[m|c])$ /$1?sub=$sub&$args? break; #lets append the subdomain to the request
	}
}

and i am not sure how. Can someone please help!

Thanks,
Art

There’s kinda a lack of context here. What’s the goal of this rewrite? This might not even be necessary depending on other factors.

But the gist of it is you’d probably do something like this:

@cf path *.cfm *.cfc
rewrite @cf {path}?sub={labels.2}&{query}

I don’t know where $sub is coming from or the significance of *.cfm or *.cfc files. If you’re proxying to an upstream, why not just set the X-Forwarded-Host header? Etc.

Next time, please fill out the help topic template. It’s important for us to understand what you’re trying to do.

1 Like

@francislavoie Sorry about not adding enough context. So the $sub gets passed in by the nginx server with this server_name ~^(?<sub>.+)\.example.com$;. The intention of the code is to only apply the rewrite to files with the extension of .cfm and .cfc

Also, import lucee-proxy.conf ONLY if the file extensions were matched.

I assume you’re working together with @lindamiles ?

I gave an answer in that topic :point_up:

This topic was automatically closed after 30 days. New replies are no longer allowed.