I have this code. I just want each of the server_name in the list to redirect to its own name https. But, if I do http://beta.example.com, it redirects to https://api.example.com (or whatever the first item in the list is)
server {
listen 80;
server_name api.example.com beta.example.com apibeta.example.com nodebeta.example.com app.example.com;
return 301 https://$server_name$request_uri;
}
You should be able to use the $host
variable instead:
server {
listen 80;
server_name api.example.com beta.example.com apibeta.example.com nodebeta.example.com app.example.com;
return 301 https://$host$request_uri;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With