1

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
  }
}
dkroy
  • 2,020
  • 2
  • 21
  • 39
  • related to http://stackoverflow.com/a/26957754 you can also try *proxy_pass http://s3-website-us-east-1.amazonaws.com/$host* – Anatoly Dec 12 '15 at 22:07

0 Answers0