When using multiple domain names for one server, how do you get the domain name currently being used in a request? I'm using the embedded variables for Nginx in it's configuration file.
I've set up OpenSSL and have a redirect that works fine for my first domain since, as you can see, I'm explicitly redirecting to it at the bottom of my config file. So an HTTP request on any of the other domains redirects to that first one for a secure connection. Is there an embedded variable I can use, similar to $request_uri
, for example, but just returns the given domain name used by the client?
Here's the server block where I'm running the redirect.
server {
listen 80;
listen [::]:80;
server_name example.com example1.com example2.com example3.com;
location / {
return 301 https://example.com$request_uri;
}
}
And the rest of my config: https://pastebin.com/HgnZ0aBe