You are trying to make your application think that it is on a path it is actually not. This can be done by rewriting destination at proxy_pass
:
location ~ ^/mysubdomain(/.*)?$ {
proxy_pass http://10.11.0.3:8080/myappname$1$is_args$args;
# this example does not include proxy_set_header for simplicity but you may need it
}
However, I would not recommend you do that in most cases. The above will help you to get a response to the initial request, but because your application will think it is on a different path, consequent requests (to static files or sub-pages) may be broken if a link will contain /myappname
in it. NGINX can rewrite URLs in proxied responses but it is another hack with its own downsides.
What you really need is to change the base URI of the application from /myappname
to /mysubdomain
. This will make it work with no hacks involved.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…