I am trying to setup an nginx proxy in front of any s3 website that I point at it. In the example below I have my DNS records customsite.com pointing to my proxy. When I don't use any variable for the destination of the proxy_pass there isn't an issue, but I want to be able to just dynamically pass the request using $host. How do I get the $host variable to behave with proxy_pass?
This Works
server {
listen 80;
location / {
add_header RequestedHost $host; # The host is returned as expected (customsite.com)
# go get it from s3
proxy_pass http://customsite.com.s3-website-us-east-1.amazonaws.com;
}
}
This Doesn't Work
server {
listen 80;
location / {
add_header RequestedHost $host;
# go get it from s3
proxy_pass http://$host.s3-website-us-east-1.amazonaws.com; # Doesn't resolve
}
}