Aliases (and any other configurable sharing a name with something in
Apache) generally don’t do the same thing as in Apache. Just use “root”
inside the location block.
is it possible to configure nginx to behave like apache ?
No.
If your use case is restricted to one of the two mentioned below, then
you might be able to fake it adequately.
nginx does not have a config option to do what you seem to want, which
is “use the incoming http Host: header value in any generated Location:
response header”.
Using “port_in_redirect”, you can auto-include either no port at all,
or whichever port the connection actually came to nginx on (which will
be one of the ports listed or implied in the “listen” directives).
If you don’t want to patch the code to add your use case, then
if you have a fixed list of redirections, you could add a number of
locations of the form