Reverse proxy handle path /user/[any-user-name]/*

1. The problem I’m having:

I would like to reverse proxy anything on localhost’s /user/[username]/* to a specific port (i.e. 8080), but with the /user/[username] stripped from the path before proxying the request. For this example anything like a \w+ regex for a username would suffice. I can’t do a full redirect, since the browsers path should still indicate /user/[username]

How would I go about this? A handle_path for just /user/* is easy enough to strip the first segment, but I can’t figure out how to include the dynamic part.

Use the path_regexp matcher to match with a regexp, use a capture group for the remainder you want to keep, then do a rewrite to that part.

@user path_regexp user ^/user/\w+(.*)$
handle @user {
	rewrite * {re.user.1}
	reverse_proxy localhost:8080
}

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