Given a certain functional (represents a distance), \begin{equation} S[x] = \int_\alpha^\beta d\lambda ~ L(\dot x(\lambda), x(\lambda), \lambda) \end{equation} where $\lambda$ is some affine parameter.
In order to minimise it, we compute the Euler-Lagrange equations and get the shortest path between $\alpha$ and $\beta$. But what if the space where $x$ live is restricted? Say $x \in A$, where $A=[0,f(\lambda)]$ is a certain domain and $\lambda\in[\lambda_0,\infty)$. How can we restrict the geodesics to be only in $A$?
One way I can think of, in practice, is to make your Lagrangian very large in the region you want to exclude, akin to having a very steep potential. This will make your geoedesics go around that region. For example, \begin{equation} L\left(\dot{x}(\lambda),x(\lambda),\lambda\right) \to L\left(\dot{x}(\lambda),x(\lambda),\lambda\right) + \alpha \, \Theta\left( x(\lambda) - f(\lambda)\right) \Theta\left(- x(\lambda) \right) \Theta( \lambda_0 - \lambda), \end{equation} excludes the region outside $A$ if you formally let $\alpha \to \infty$.