Host header with nginx proxy_pass
I recently moved this blog and evilstreak’s to a VM on my stonking new server from Hetzner: 24GB. Woo!
But I made a booboo in switching from lighttpd to nginx. It turns out that the proxy_pass
directive for nginx overwrites the Host header from the request with the proxy host. This in turn means that jsgi-vhost will fallback to the default host: in this case it happened to be evilstreak’s blog. Oops. The correct config invocation for nginx to preserve the host header from the request is:
server {
listen 80;
server_name ashberlin.co.uk;
location /blog/ {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $http_host;
}
}
So to those of you who read my RSS feed - sorry for the confusing posts over night. That’s what I get for playing at being a sysadmin late at night.